|
|
@ -37,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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |