public void ShouldNotCreateUser_IfNameisInvalid(string firstName, string lastName) { // arrange SocialNetwork socialNetwork = new SocialNetwork(); //string firstName = "aaaaa5ddddd", lastName = "Ice"; // act bool result = socialNetwork.CreateUser(firstName, lastName); // assert Assert.False(result, "CreateUser returned true"); Assert.Empty(socialNetwork.allUsers); }
public void ShouldNotCreateUser_WhenUserAlreadyExists() { // arrange SocialNetwork socialNetwork = new SocialNetwork(); string firstName = "Gordon", lastName = "Brown"; User existingUser = new User(firstName, lastName); socialNetwork.allUsers.Add(existingUser); // act bool result = socialNetwork.CreateUser(firstName, lastName); // assert Assert.False(result, "Function returned true"); Assert.Single(socialNetwork.allUsers); }
public void ShouldCreateUser_ForCorrectParameters() { // arrange string firstName = "Nils", lastName = "Holgersson"; SocialNetwork socialNetwork = new SocialNetwork(); // act bool result = socialNetwork.CreateUser(firstName, lastName); // assert Assert.True(result, "Did not return true"); // assert that the created User actually is in the list allUsers bool exist = UserExist(socialNetwork.allUsers, firstName, lastName); Assert.True(exist, "No user with that name exist in allUsers"); }