I have a class say User with interface in constructor paramater. Could someone please help me how I can create fake object with mocked interface.
Right now It is throwing an exception. Is there any way to override it?
I have a class say User with interface in constructor paramater. Could someone please help me how I can create fake object with mocked interface.
Right now It is throwing an exception. Is there any way to override it?
First -- There's a typo in your post title, please fix that so others can find this post.
Second -- This behavior is clearly documented in AutoBogus' Readme, under Binders.
So you're going to want to add one of those NuGet packages to your project and use it to configure your auto generator.
Example, using NSubstitute (my personal favorite C# mocking library):
This injects the
User
constructor with what essentially amounts toSubstitute.For<IValidate>()
.