public void DeteUser_Should_Delete_ApropriateUser() { // Arrange var repository = new TestUserRepository(); var userToDelete = repository.GetUser(1); // Act repository.DeleteUser(userToDelete); var userDeleted = repository.GetUser(1); // Assert Assert.AreEqual(repository.GetAllUsers().Count(), 14); Assert.IsNull(userDeleted); }
public void GetUserWithID_Should_Return_Null_For_FalseID() { // Arrange var repository = new TestUserRepository(); // Act var user = repository.GetUser(20); // Assert Assert.IsNull(user); }
public void GetUser_ShouldReturn_Null_ForFalse_UserName() { // Arrange IUserRepository repository = new TestUserRepository(); // Act User user = repository.GetUser("BOGUS"); // Assert Assert.IsNull(user); }
public void GetUser_ShouldReturn_UserObject_ForTrue_UserName() { // Arrange IUserRepository repository = new TestUserRepository(); // Act User user = repository.GetUser("UserName1"); // Assert Assert.IsNotNull(user); Assert.AreEqual("UserName1", user.UserName); }
public void UpdateUser_Should_Change_Common_UserData() { // Arrange var repository = new TestUserRepository(); var user = repository.GetUser(1); //Change the data user.UserName = "******"; user.Password = "******"; user.Email = "*****@*****.**"; //Act repository.UpdateUser(user); var updatedUser = repository.GetUser(1); //Assert Assert.IsNotNull(user); Assert.AreEqual(user.UserName, "NewUserName"); Assert.AreEqual(user.Password, "NewPassword"); Assert.AreEqual(user.Email, "*****@*****.**"); }
public void AddUser_Should_AddUserToData() { // Arrange var repository = new TestUserRepository(); var user = new User() { UserID = 20, UserName = "******", Password = "******", Email = "TestEmail" }; // Act repository.AddUser(user); var theNewUserViaID = repository.GetUser(20); var theNewUserViaUserName = repository.GetUser("TestUserName"); //Assert Assert.AreEqual(repository.GetAllUsers().Count(), 16); Assert.IsNotNull(theNewUserViaID); Assert.IsNotNull(theNewUserViaUserName); }
public void GetUserWithID_Should_Return_User_For_TrueID() { // Arrange var repository = new TestUserRepository(); // Act var user = repository.GetUser(1); // Assert Assert.IsNotNull(user); Assert.AreEqual(user.UserName, "UserName1"); Assert.AreEqual(user.Password, "Password1"); }
public void Register_Should_Add_User_To_Repository_And_Return_Success() { //Arrange var repository = new TestUserRepository(); var service = new UserService(repository, null); var model = new User() { UserName = "******", Password = "******", Email = "*****@*****.**" }; //Act var result = service.RegisterUser(model); var registeredUser = repository.GetUser("NewUserName"); //Assert Assert.IsTrue(result.Status); Assert.IsTrue(result.ErrorCodes.Count == 0); Assert.IsNotNull(registeredUser); }