public void TestLoginUserServiceCreate() { List <LoginUser> readAll = new List <LoginUser>() { new LoginUser() { IsActivated = true, IsAdmin = false, //IsUserName = "", UserInfo = new UserInfo() { Email = "*****@*****.**" }, PasswordHash = new byte[] { 1, 2, 3 }, PasswordSalt = new byte[] { 1, 2, 3 }, Id = 99 } }; LoginUser userBeforeCreate = new LoginUser() { IsActivated = true, IsAdmin = false, //UserName = "", UserInfo = new UserInfo() { Email = "*****@*****.**" }, PasswordHash = new byte[] { 1, 2, 3 }, PasswordSalt = new byte[] { 1, 2, 3 } }; LoginUser userAfterCreate = new LoginUser() { PasswordHash = userBeforeCreate.PasswordHash, PasswordSalt = userBeforeCreate.PasswordSalt, UserInfo = new UserInfo() { Email = userBeforeCreate.UserInfo.Email }, IsActivated = userBeforeCreate.IsActivated, IsAdmin = userBeforeCreate.IsAdmin, Id = 1 }; _mockRepo.Setup(repo => repo.ReadAll()).Returns(readAll); _mockRepo.Setup(repo => repo.Create(userBeforeCreate)).Returns(userAfterCreate); Assert.IsTrue(_service.Create(userBeforeCreate) != null); _mockRepo.Verify(x => x.Create(It.IsAny <LoginUser>()), Times.Once); }