bUnit and AutoFixture with Moq #307
thopdev
started this conversation in
Show and tell
Replies: 1 comment 1 reply
-
Thanks for sharing @thopdev. I am getting the hang of AutoFixture myself at work, so its nice to see that it works well with bUnit as well. What is the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
AutoFixture allows you to automatically create objects with random, Mocks etc.. values.
Last week I tried using bUnit in combination with AutoFixture but i got a exception when let AutoFixture generate the TestContext.
System.InvalidOperationException: 'Services cannot be added to provider after it has been initialized.'
Now i still wanted to use AutoFixture so i went into a little deeper into it to it.
AutoFixture allows to customize certain objects so i took a advanced of that and when a certain mock is requested it automatically inserts it into the dependency container from bUnit. I used the following code.
AddServiceCustomization
AddAllServicesCustomization
AutoMoq Data attribute
Example test
If you have any other questions, suggestions or other approaches please let me know.
Beta Was this translation helpful? Give feedback.
All reactions