3 Commits

  1. 38
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

38
projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

@ -16,7 +16,7 @@ public class CustomersTest extends TestCase {
assertTrue(nicknameIsAvailable);
}
public void test_registerUser() {
public void test_registerSingleUser() {
// Given
Customers customers = new Customers();
String expectedNickNameInput = "Mougli";
@ -30,7 +30,6 @@ public class CustomersTest extends TestCase {
assertTrue(null != expectedNewUser);
String expectedNickNameGotBack = expectedUser.nickName;
System.out.println(expectedNickNameGotBack);
// When
boolean userRegistered = expectedNickNameGotBack.equals(expectedNickNameInput);
@ -38,4 +37,39 @@ public class CustomersTest extends TestCase {
assertTrue(userRegistered);
}
/**
* Register multiple Users and then search for them in the same order.
*/
public void test_registerMultipleUsers() {
// Given
Customers customers = new Customers();
String[] expectedNickNamesInput = {"Mougli", "Tarkan", "beastMaster64", "BlaBlaPew", "MuchDoge_321"};
User[] expectedNewUsers = new User[expectedNickNamesInput.length];
for (int i = 0; i < expectedNickNamesInput.length; i++) {
// Create user
expectedNewUsers[i] = new User(expectedNickNamesInput[i]);
// Add user
customers.registerUser(expectedNewUsers[i]);
}
// Get the expected Users
User foundUser;
String expectedNickNameGotBack;
boolean userRegistered;
for (int i = 0; i < expectedNickNamesInput.length; i++) {
// Get user
foundUser = customers.getByNickname(expectedNickNamesInput[i]);
assertTrue(null != foundUser);
// When
expectedNickNameGotBack = foundUser.nickName;
userRegistered = expectedNickNameGotBack.equals(expectedNickNamesInput[i]);
// Then
assertTrue(userRegistered);
}
}
}
Loading…
Cancel
Save