public async Task CreateUserSuccess() { var ip = IPAddress.Parse("80.80.80.45"); A.CallTo(() => _passwordHash.GenerateHashFromPassword("My password")).Returns("hashedPassword"); A.CallTo(() => _userRepositoryService.FindAsync(A <Email> ._)).Returns(Task.FromResult <User>(null)); A.CallTo(() => _userRepositoryService.FindAsync(A <string> ._)).Returns(Task.FromResult <User>(null)); A.CallTo(() => _userRepositoryService.InsertAsync(A <User> ._)).Returns(1); var response = await _userService.CreateUserAsync(new User { Email = new Email("*****@*****.**"), Password = "******", Username = "******" }, ip); A.CallTo(() => _userRepositoryService.InsertAsync( A <User> .That.Matches(user => user.Email.Value == "*****@*****.**" && user.Password == "hashedPassword" && user.Username == "Username" ) )).MustHaveHappened(); A.CallTo(() => _whiteListRepostirotyService.AddWhitelistedIpAsync ( A <int> .That.Matches(id => id == 1), A <IPAddress> .That.Matches(i => i.ToString() == ip.ToString()) )).MustHaveHappened(); A.CallTo(() => _emailService.SendValidationEmail(A <User> .That.Matches(u => u.Id == 1), A <string> ._)).MustHaveHappened(); A.CallTo(() => _userRepositoryService.FindAsync(A <Email> .That.Matches(e => e.Value == "*****@*****.**"))).MustHaveHappened(); A.CallTo(() => _userRepositoryService.FindAsync(A <string> ._)).MustHaveHappened(); A.CallTo(() => _passwordHash.GenerateHashFromPassword("My password")).MustHaveHappened(); Assert.True(response.Success); }