Well, as was said in my other question , it AutoMoq
does not use AutoFixture by default. This is great and easy to solve by setting up and installing ReturnsUsingFixture
.
But can this be adjusted using Auto Fixture Data Theory?
So, we have a custom attribute AutoDataAttribute, which I will name [MyAutoData]
. And there we call and configure a set of settings, such as AutoConfiguredMoqCustomization
, configure it to create webapi controllers and register many user-generated generators. Thus, we were able to pull the FULL configuration template into some basic configuration files. We even set up an attribute MyAutoData
for system tests, so if you ask, say, Id<Account>
it will go and create a new account using the actual webapi calls and return a valid account identifier.
But how can you handle the fact that it AutoMoq
returns to set up a method ? Here is an example:
[Theory, MyAutoData]
public async Task Test(Mock<ICqrsService> mockService, TheRequest request)
{
mockService.Setup(service => service.CreateAsync<TheRequest>(It.IsAny<TheRequest>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(result);
}
MyAutoData
( , ). AutoMoq , . .
, AutoFixture , ? AutoMoq, .ReturnsUsingFixture(fixture)
? , ?