Browse Source

Added: Count Registered Users and Test

feature-pr/user
Maxim Volkov 3 years ago
parent
commit
012ad38d16
  1. 4
      projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java
  2. 17
      projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java

4
projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java

@ -24,4 +24,8 @@ public class Customers {
public User getByNickname(String nickname) { public User getByNickname(String nickname) {
return pool.get(nickname); return pool.get(nickname);
} }
public int getCountOfUsers() {
return pool.size();
}
} }

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

@ -105,5 +105,22 @@ public class CustomersTest extends TestCase {
assertEquals(userToRemove, removedUser.nickName); 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);
}
} }
Loading…
Cancel
Save