From 012ad38d16eb2724ee39375f77aa98eea1a3e2d3 Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 05:20:10 +0100 Subject: [PATCH] Added: Count Registered Users and Test --- .../de/hs_fulda/ciip/projjpn/Customers.java | 4 ++++ .../de/hs_fulda/ciip/projjpn/CustomersTest.java | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java index c56cde6..174016e 100644 --- a/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java +++ b/projjpn/src/main/java/de/hs_fulda/ciip/projjpn/Customers.java @@ -24,4 +24,8 @@ public class Customers { public User getByNickname(String nickname) { return pool.get(nickname); } + + public int getCountOfUsers() { + return pool.size(); + } } diff --git a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java index 2df7fd8..1a2bf5f 100644 --- a/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java +++ b/projjpn/src/test/java/de/hs_fulda/ciip/projjpn/CustomersTest.java @@ -105,5 +105,22 @@ public class CustomersTest extends TestCase { 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); + + } }