From a5d54b0ea60673b511c23c830bd4f2c84efe60ee Mon Sep 17 00:00:00 2001 From: Maxim Volkov Date: Thu, 17 Feb 2022 04:38:33 +0100 Subject: [PATCH] Added: Register Multiple Users Test --- .../hs_fulda/ciip/projjpn/CustomersTest.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) 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 33b6cba..e89d5e2 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 @@ -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); + } + } }