|
@ -16,6 +16,22 @@ public class CustomersTest extends TestCase { |
|
|
assertTrue(nicknameIsAvailable); |
|
|
assertTrue(nicknameIsAvailable); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void test_nicknameIsTaken() { |
|
|
|
|
|
// Given |
|
|
|
|
|
Customers customers = new Customers(); |
|
|
|
|
|
String availableNickname = "beastMaster64"; |
|
|
|
|
|
String takenNickname = "beastMaster64"; |
|
|
|
|
|
User userToRegister = new User(availableNickname); |
|
|
|
|
|
|
|
|
|
|
|
customers.registerUser(userToRegister); |
|
|
|
|
|
|
|
|
|
|
|
// When |
|
|
|
|
|
boolean nicknameIsTaken = !customers.nickNameAvailable(availableNickname); |
|
|
|
|
|
|
|
|
|
|
|
// Then |
|
|
|
|
|
assertTrue(nicknameIsTaken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void test_registerSingleUser() { |
|
|
public void test_registerSingleUser() { |
|
|
// Given |
|
|
// Given |
|
|
Customers customers = new Customers(); |
|
|
Customers customers = new Customers(); |
|
@ -72,4 +88,39 @@ public class CustomersTest extends TestCase { |
|
|
assertTrue(userRegistered); |
|
|
assertTrue(userRegistered); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void test_removeRegisteredUser() { |
|
|
|
|
|
// Given |
|
|
|
|
|
Customers customers = new Customers(); |
|
|
|
|
|
String userToRemove = "beastMaster64"; |
|
|
|
|
|
User userToRegister = new User("beastMaster64"); |
|
|
|
|
|
customers.registerUser(userToRegister); |
|
|
|
|
|
|
|
|
|
|
|
// When |
|
|
|
|
|
boolean userExists = !customers.nickNameAvailable(userToRemove); |
|
|
|
|
|
assertTrue(userExists); |
|
|
|
|
|
|
|
|
|
|
|
// Then |
|
|
|
|
|
User removedUser = customers.deleteUser(userToRemove); |
|
|
|
|
|
assertEquals(userToRemove, removedUser.nickName); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void test_registerAndCountUsers() { |
|
|
|
|
|
// Given |
|
|
|
|
|
Customers customers = new Customers(); |
|
|
|
|
|
int expectedRegisteredUsers = 20; |
|
|
|
|
|
int actualRegisteredUsers = -1; |
|
|
|
|
|
String nickname; |
|
|
|
|
|
|
|
|
|
|
|
// Prepare |
|
|
|
|
|
for(int i = 0, j = 1; i < expectedRegisteredUsers; i++, j++) { |
|
|
|
|
|
nickname = "beastMaster_" + j; |
|
|
|
|
|
customers.registerUser(new User(nickname)); |
|
|
|
|
|
} |
|
|
|
|
|
actualRegisteredUsers = customers.getCountOfUsers(); |
|
|
|
|
|
assertEquals(expectedRegisteredUsers, actualRegisteredUsers); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |