public void GetByIdTest_ValidId_ShouldReturnValidEntity() { User entity = new User() { Username = "******", Nickname = "TheTestUser", AuthCode = "0123456789012345678901234567890123456789", SessionKey = "01234567890123456789012345678901234567890123456789" }; this.userRepository.Add(entity); User foundEntity = this.userEntities.Find(entity.Id); Assert.AreSame(entity, foundEntity); }
public void AddTest_EntityIsValid_ShouldBeAddedSuccessfuly() { User entity = new User() { Username = "******", Nickname = "TheTestUser", AuthCode = "0123456789012345678901234567890123456789", SessionKey = "01234567890123456789012345678901234567890123456789" }; this.userRepository.Add(entity); User foundEntity = this.userEntities.Find(entity.Id); Assert.IsTrue(entity.Id != 0); Assert.IsNotNull(foundEntity); Assert.AreSame(entity, foundEntity); }
public void UpdateTest_InvalidUpdateEntity_ShouldThrowArgumentNullException() { User entity = new User() { Username = "******", Nickname = "TheTestUser", AuthCode = "0123456789012345678901234567890123456789", SessionKey = "01234567890123456789012345678901234567890123456789" }; this.userRepository.Add(entity); User userToUpdateWith = null; User updatedUser = this.userRepository.Update(entity.Id, userToUpdateWith); }
public void UpdateTest_ValidUpdate() { User entity = new User() { Username = "******", Nickname = "TheTestUser", AuthCode = "0123456789012345678901234567890123456789", SessionKey = "01234567890123456789012345678901234567890123456789" }; this.userRepository.Add(entity); User userToUpdateWith = new User() { Username = "******", Nickname = "UpdatedNickname", AuthCode = "UpdatedNickname5678901234567890123456789", SessionKey = "UpdatedNickname56789012345678901234567890123456789" }; User updatedUser = this.userRepository.Update(entity.Id, userToUpdateWith); Assert.AreSame(entity, updatedUser); Assert.AreEqual(updatedUser.Nickname, userToUpdateWith.Nickname); Assert.AreEqual(updatedUser.Username, userToUpdateWith.Username); Assert.AreEqual(updatedUser.AuthCode, updatedUser.AuthCode); }
public void UpdateTest_InvalidEntityId() { int invalidId = -1; User entity = new User() { Username = "******", Nickname = "TheTestUser", AuthCode = "0123456789012345678901234567890123456789", SessionKey = "01234567890123456789012345678901234567890123456789" }; this.userRepository.Add(entity); User userToUpdateWith = new User() { Username = "******", Nickname = "UpdatedNickname", AuthCode = "UpdatedNickname5678901234567890123456789", SessionKey = "UpdatedNickname56789012345678901234567890123456789" }; User updatedUser = this.userRepository.Update(invalidId, userToUpdateWith); Assert.IsNull(updatedUser); }