Closed cviktor closed 4 years ago
Hey @cviktor
It does get a little bit complicated than passing the binder via the constructor because the binder can be overridden by the config setup. I will do some investigations into the impact of passing to the underlying Bogus Faker
and see whether other changes are needed as well.
Nick.
Hey @nickdodd79
Thanks! I think the important part is that it seems like an inconsistent behavior for me because the base class and the derived AutoFaker will basically use a different Binder so it can cause some strange results, which is not logical for me, given that the Bogus.Faker
is prepared to use a custom binder.
(by the way awesome lib, big thanks, we are ramping up our testing efforts and it helps with the boilerplate codes a lot 👍 )
Hey @cviktor
I have made the changes to pass the AutoBinder
instance to the underlying Faker
. It didn't seem to have any adverse impact, so I have just release it as part of v2.8.
Nick.
Works perfectly thanks for the fast response. It helps me to create a custom binder to work with with properties in the base classes that has private setters, so I can create rules for them. (If someone needs this info in the future)
I am trying to create a custom Binder to handle private setters in base classes, but AutoFaker class does not pass the binder argument to the base class. I think the problem is in the following line:
https://github.com/nickdodd79/AutoBogus/blob/master/src/AutoBogus/AutoFaker%5BT%5D.cs#L48 It should pass the custom binder as an argument because the Binder base class uses it in the constructor.