-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full example of using IObjectMother? #82
Comments
Ah, I think I am on the right track: In addition to defining the implementation of IObjectMother, which I am using to create an NSubstitute for an "IDataRepository" you also need to make that available, by referring to the target interface within the Given method. So the ObjectMother is defined somewhere in the same assembly as the tests: Option 1: Implement IObjectMother
Option 2: Use ObjectMother abstract class
And then, in the definition of the tests:
If this line is not included, AutoFac will not resolve the type. Which makes sense. And is very clean. My comment regarding the some clearer samples, to boost the popularity of this project, still stands - I'll have a stab at creating one myself, and post it for comment. |
Hi David, The |
As per the title, I am a little confused as to how to use the ObjectMother feature of this library:
The snippets in the documentation are not quite in sync, referring to:
EntityMother.CreateACustomer() is an apparently static method, perhaps a standard Builder pattern, but the EntityMother implementation is not described, so I am not sure. Other snippets refer to an apparently different approach, by implementing the IObjectMother interface:
My understanding is that implementations of IObjectMother within the same assembly should be registered with the AutoFac container - but I am also not sure if this also needs to be referred to in some way in the Given method.
Any chance of a simple but complete sample? I have a feeling this project would be pretty popular, If there were samples that made the usage a little clearer... thanks!
The text was updated successfully, but these errors were encountered: