Closed GoogleCodeExporter closed 8 years ago
Hi Alex,
I'm not sure I fully understand why you want to ignore the initialization in
the constructor, wouldn't that defeat the purpose of the class's constructor?
Wouldn't it be easier to set the individual properties to a non-null value
explicityly using the .With(...) extention method?
e.g.
Person p = Builder<Person>
.CreateNew()
.With(p => p.Zip = 93837)
.And(p => p.Name = "name")
.Build()
Doing this, you allow the class to be constructed as the author intended as
well as explicitly set up the properties you want.
Or perhaps you could create a new constructor for the class and use NBuilder's
method for creating a class using a specific constructor...
Does that help at all? If not, can you explain further so I can better
understand the problem you are experiencing?
Original comment by joshuajr...@gmail.com
on 17 Feb 2011 at 1:19
I think I have the same issue. The thing is, we will most likely use nbuilder
for testing. But our classes should be constructed with empty fields. When we
set values to them inside the constructor, Nbuilder ignores them and only
changes the null ones (upon construction).
I know how to use the With but that might not be that helpful to big classes
such as ours. If i'm going to use with, I might as well set these test data
manually (besides for lists that is).
Hope you can help us and thanks in advance.
Original comment by Quatrei...@gmail.com
on 17 Nov 2011 at 8:34
Hi again,
I've already found the answer to my problem in Issue 77. Thanks again!
Original comment by Quatrei...@gmail.com
on 17 Nov 2011 at 8:49
No response from person who originally raised issue. Since there is a
workaround for this issue which respects a class' design I'm closing this issue
as being invalid.
Original comment by joshuajr...@gmail.com
on 2 Dec 2011 at 12:57
Original issue reported on code.google.com by
mystacko...@googlemail.com
on 21 Jan 2011 at 9:51