public string CheckRegistration(User newUser) { if (string.IsNullOrEmpty(newUser.UserName) || string.IsNullOrEmpty(newUser.Password)) { return(NullCred); } else if (newUser.UserName.Length > UserNameMaxLength) { return(UserNameTooLong); } else { User userAlreadyExists = _usersAccessor.FindUser(newUser.UserName); if (userAlreadyExists != null) { return(UserAlreadyExists); } else { _usersAccessor.InsertUser(newUser); Event defaultEvent = new Event() { DateCreated = DateTime.Now, Description = "You created this account.", UserName = newUser.UserName }; _eventsAccessor.InsertEvent(defaultEvent); return(SuccessfulRegistration); } } }
public void InsertUser_WithNewNonExistingUser_ShouldFindUserInDB() { //Arrange User userToInsert = new User() { UserName = "******", Password = "******" }; User foundUser = new User(); //Act _usersAccessor.InsertUser(userToInsert); foundUser = _usersAccessor.FindUser(userToInsert.UserName); //Assert Assert.That(foundUser.UserName, Is.EqualTo("newTestUserName")); Assert.That(foundUser.Password, Is.EqualTo("e1129e4321dc4dbd4107c58c9b9d083bf63cef947fcc6786e15af61a6540d63b")); //Teardown this.DeleteUser(userToInsert.UserName); }