I haven't done too many unit tests and I'm running into a problem I don't understand. This is my unit test.
[TestMethod]
public void PostAccount_Ok_SaveSuccesful()
{
// Arrange
var account = new AccountDto
{
Email = "test@test.com",
UserName = "myuser"
};
// Act
var result = _accountController.PostAccount(account).Result;
// Assert
Assert.IsNotNull(result);
Assert.IsInstanceOfType(result, typeof(OkNegotiatedContentResult<AccountDto>));
}
The _accountController uses a mockup of my unit of work
var uow = new Mock<IUnitOfWork>();
_accountController = new AccountController(uow.Object);
Now the first time I run this test everything goes well. But the second time I get the error that the user already exists. When I check my database it is not stored in there, so it is not using the database to store the user. Can anyone explain to me where it is stored then? or why it thinks it is stored. Help is much appreciated.
Aucun commentaire:
Enregistrer un commentaire