From 7bc3550c97aa7c6110394f1b773e2fbc72bdb20f Mon Sep 17 00:00:00 2001 From: AdventureT Date: Sun, 10 Dec 2023 17:51:28 +0100 Subject: [PATCH] Added TUser Tests --- .../UnitTests/Source/TKernel/TUser_Tests.cpp | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/Tools/UnitTests/Source/TKernel/TUser_Tests.cpp b/Tools/UnitTests/Source/TKernel/TUser_Tests.cpp index 6e93dfa..7abaeb3 100644 --- a/Tools/UnitTests/Source/TKernel/TUser_Tests.cpp +++ b/Tools/UnitTests/Source/TKernel/TUser_Tests.cpp @@ -3,10 +3,40 @@ TOSHI_NAMESPACE_USING +static TUser testUser("Test"); +static TUser testUser2("AdventureT"); + TEST_CASE("Register User", "[TUser]") { - TUser user("AdventureT"); - TSHORT iUserID = user.Register(); + TSHORT iUserID = testUser.Register(); + + REQUIRE(iUserID != -1); + REQUIRE(TUserHandler::GetSingleton().FindUser("Test")); + REQUIRE(testUser.IsRegistered()); + + iUserID = testUser2.Register(); + REQUIRE(iUserID != -1); - REQUIRE(user.IsRegistered()); + REQUIRE(TUserHandler::GetSingleton().FindUser("AdventureT")); + REQUIRE(testUser.IsRegistered()); + + REQUIRE(TUserHandler::GetSingleton().FindUser("Toshi")); // This user is created in the ctor of TKernelInterface + REQUIRE(TUserHandler::GetSingleton().GetUserCount() == 3); +} + +TEST_CASE("Deregister User", "[TUser]") +{ + testUser.Deregister(); + + REQUIRE(!TUserHandler::GetSingleton().FindUser("Test")); + REQUIRE(!testUser.IsRegistered()); + + testUser2.Deregister(); + + REQUIRE(!TUserHandler::GetSingleton().FindUser("AdventureT")); + REQUIRE(!testUser2.IsRegistered()); + + REQUIRE(TUserHandler::GetSingleton().FindUser("Toshi")); // This user is created in the ctor of TKernelInterface + // The Users are still present, but not Registered + REQUIRE(TUserHandler::GetSingleton().GetUserCount() == 3); } \ No newline at end of file