From 084e0de6ec2cd73d19bea3981c892a1a693a7cd1 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:23:11 -0800 Subject: [PATCH 1/7] changed everything so that the branch is running again --- .../TeamHobby.HobbyProjectGenerator.sln | 28 ++----------------- Source Code/main/Controller.cs | 2 +- Source Code/main/main.csproj | 1 - 3 files changed, 3 insertions(+), 28 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln index 7868d26..60e405e 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln @@ -8,6 +8,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.Te {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} = {AA48A66C-FA36-4AF9-A782-CEC22838EB8F} {2E7193B8-86B6-48DA-9671-CD84615A5F5D} = {2E7193B8-86B6-48DA-9671-CD84615A5F5D} EndProjectSection +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Models", "..\TeamHobby.HobbyProjectGenerator.Models\TeamHobby.HobbyProjectGenerator.Models.csproj", "{75DED6C2-D404-4E71-A58B-0F616DB5C062}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "main", "..\main\main.csproj", "{30C7EBF3-3957-46E5-86C1-C13356841ECA}" @@ -16,12 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Logging", "..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj", "{C0494115-838E-43A3-8896-133E5D1E874A}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.Logging.Tests", "..\TeamHobby.HobbyProjectGenerator.Logging.Tests\TeamHobby.HobbyProjectGenerator.Logging.Tests.csproj", "{CA8D11CF-807C-4C90-A529-0371F73518F6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" @@ -30,7 +27,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject TeamHobby.HobbyProjectGenerator.csproj = TeamHobby.HobbyProjectGenerator.csproj EndProjectSection -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,13 +35,9 @@ Global EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Debug|x86.ActiveCfg = Debug|Any CPU {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.ActiveCfg = Release|Any CPU {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = Release|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.ActiveCfg = Release|Any CPU - {5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|x86.Build.0 = Release|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Debug|Any CPU.Build.0 = Debug|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.ActiveCfg = Release|Any CPU {75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -53,39 +45,23 @@ Global {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.ActiveCfg = Release|Any CPU {30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|Any CPU.Build.0 = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.ActiveCfg = Debug|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|x86.Build.0 = Debug|Any CPU - {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = Debug|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.ActiveCfg = Release|Any CPU {B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Release|Any CPU.Build.0 = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|Any CPU.Build.0 = Release|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.ActiveCfg = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|x86.Build.0 = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C0494115-838E-43A3-8896-133E5D1E874A}.Release|Any CPU.Build.0 = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Debug|Any CPU.Build.0 = Debug|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.ActiveCfg = Release|Any CPU {2E7193B8-86B6-48DA-9671-CD84615A5F5D}.Release|Any CPU.Build.0 = Release|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.ActiveCfg = Debug|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|x86.Build.0 = Debug|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = Release|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.ActiveCfg = Release|Any CPU - {C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|x86.Build.0 = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.ActiveCfg = Debug|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|x86.Build.0 = Debug|Any CPU + {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.ActiveCfg = Release|Any CPU - {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 06cf78c..444e89f 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -144,7 +144,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main //Console.WriteLine("Writing completed. "); } } - } } + diff --git a/Source Code/main/main.csproj b/Source Code/main/main.csproj index 73a9e47..6236e85 100644 --- a/Source Code/main/main.csproj +++ b/Source Code/main/main.csproj @@ -16,7 +16,6 @@ - From bca0875ec7267ecc49203441c6daea7f590f956a Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:54:23 -0800 Subject: [PATCH 2/7] rechecked DDL for full DB --- Source Code/main/Controller.cs | 34 ++++++++-------- src/dbCode/UserManagementDDL.txt | 2 +- src/dbCode/fullDDL.txt | 66 ++++++++++++++------------------ 3 files changed, 46 insertions(+), 56 deletions(-) diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index 444e89f..d4dcfd0 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -29,6 +29,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Loop Admin login while (mainMenu is true) { + // Admin Sign in GetCredentials credentials = new GetCredentials(); Console.WriteLine("\nPlease Enter Admin Credentials " + @@ -61,6 +62,21 @@ namespace TeamHobby.HobbyProjectGenerator.Main "PASSWORD=Teamhobby;" + "OPTION=3"; IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // While loop to keep this running forever with UserManagement + // Testing archive Manager + //while (true) + //{ + string currentDate = DateTime.Now.ToString("dd"); + string currentTime = DateTime.Now.ToString("T"); + //Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); + if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) + { + ArchiveManager archive = new ArchiveManager(datasource); + archive.Controller(); + } + //} + // Create manager class from UserManagement SystemAccountManager manager = new SystemAccountManager(); @@ -82,22 +98,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main } - /* // While loop to keep this running forever with UserManagement - // Testing archive Manager - //while (true) - //{ - string currentDate = DateTime.Now.ToString("dd"); - string currentTime = DateTime.Now.ToString("T"); - Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime); - if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM")) - { - ArchiveManager archive = new ArchiveManager(datasource); - archive.Controller(); - } - //}*/ - - - //Creating the folder Archive //Console.WriteLine("Creating a new folder ..."); //archive.CreateArchiveFolder(); @@ -127,8 +127,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main //sqlDS.RemoveEntries(); - - // 2.Inserting Data into the database: //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + // "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');"; diff --git a/src/dbCode/UserManagementDDL.txt b/src/dbCode/UserManagementDDL.txt index c4d451b..d8775ac 100644 --- a/src/dbCode/UserManagementDDL.txt +++ b/src/dbCode/UserManagementDDL.txt @@ -34,4 +34,4 @@ INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedD INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'Jacob', '2021-12-13 03:25:14'), -('regular', 'Colin', '2021-12-13 03:25:14'); +('regular', 'Jacob', '2021-12-13 03:25:14'); diff --git a/src/dbCode/fullDDL.txt b/src/dbCode/fullDDL.txt index f77d833..ffcc31a 100644 --- a/src/dbCode/fullDDL.txt +++ b/src/dbCode/fullDDL.txt @@ -2,52 +2,44 @@ create database Hobby; use hobby; +create table roles +( + Role varchar(50) charset utf8mb3 not null, + CreatedBy varchar(200) charset utf8mb3 not null, + CreatedDate datetime not null, + constraint role_pk + primary key (Role) +); + create table users ( UserName varchar(50) charset utf8mb3 not null primary key, - Password varchar(50) charset utf8mb3 null, - RoleID int auto_increment, - IsActive int default 1 null, - CreatedBy varchar(50) charset utf8mb3 null, - CreatedDate datetime null, - constraint users_UserName_uindex - unique (UserName), - constraint users_roles_RoleID_fk - foreign key (RoleID) references roles (RoleID) + Password varchar(50) charset utf8mb3 not null, + Role varchar(50) charset utf8mb3 not null, + IsActive int default 1 not null, + CreatedBy varchar(50) charset utf8mb3 not null, + CreatedDate datetime not null, + Email varchar(50) null, + constraint users_Email_uindex + unique (Email), + constraint userRole_fk + foreign key (Role) references roles (Role) ); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Colin ', 'Waffle', 'Jacob', '2021-12-13 04:27:42'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Danny', 'Spartan', 'Jacob', '2021-12-13 04:29:54'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Jacob', 'Teamhobby1234', 'SystemCreator', '2021-12-13 03:25:14'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Long', 'Joystick', 'Jacob', '2021-12-13 04:29:57'); -INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Rifat', 'ApproveDar', 'Jacob', '2021-12-13 04:29:55'); + +INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES +('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null), +('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null), +('Jacob', 'Teamhobby1234', 'Admin', 1, 'SystemCreator', '2021-12-13 03:25:14', null), +('Long', 'Joystick', 'regular', 1, 'Jacob', '2021-12-13 04:29:57', null), +('Rifat', '1234', 'Admin', 1, 'Jacob', '2021-12-13 04:29:55', null); -create table roles -( - RoleID int auto_increment - primary key, - Role varchar(50) charset utf8mb3 null, - CreatedBy varchar(200) charset utf8mb3 null, - CreatedDate datetime null -); +INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES +('Admin', 'Jacob', '2021-12-13 03:25:14'), +('regular', 'Jacob', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('Admin', 'SystemCreator', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Colin', '2021-12-13 03:25:14'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:44'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:46'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:47'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:49'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:50'); -INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES ('regular', 'Jacob', '2021-12-13 03:37:51'); - - -alter table users - add constraint users_roles_RoleID_fk - foreign key (RoleID) references roles (RoleID); SET Global innodb_file_per_table=ON; -- SET GLOBAL innodb_file_format='Barracuda'; From 510ea554213f07555f53db171c41678de898d25f Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 02:57:01 -0800 Subject: [PATCH 3/7] changed return strings to match design diagram --- .../SystemAccountManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs index e8eb903..49b0e48 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator.UserManagement/SystemAccountManager.cs @@ -286,7 +286,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement } else { - return "Database Timed out"; + return "User does not exist"; } break; // Enable account @@ -301,7 +301,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement } else { - return "Database Timed out"; + return "User does not exist"; } break; // View logs From 9c0472f061549b17683cab636410c44e04c1bc26 Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 13:30:22 -0800 Subject: [PATCH 4/7] Update UnitTest1.cs --- .../UnitTest1.cs | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index 4f483ad..eca9743 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -1,13 +1,47 @@ +using System; using Xunit; +using Xunit.Abstractions; +using System.Threading; namespace TeamHobby.UserManagement.xTests { public class UnitTest1 { - [Fact] - public void Test1() + + ITestOutputHelper output; + public Example(ITestOutputHelper output) { + this.output = output; + } + [Fact] + public void SingleOperationinFiveSec() + { + DateTime start = DateTime.Now; + Thread.Sleep(5000); + // create a file + DateTime end = DateTime.Now; + TimeSpan timeSpan = (end - start); + var sec = timeSpan.TotalSeconds; + //throw new Exception(sec.ToString()); + if (sec > 1) + { + throw new Exception("Greater than 5 seconds"); + } + throw new Exception("Less than 5 seconds"); + //output.WriteLine("check"); + //output.WriteLine("Elapsed time is {0} ms", timeSpan.TotalSeconds); + + var s = DateTime.Now; + output.WriteLine(s); + output.WriteLine("Time is ", DateTime.Now); + aTimer.Start(); + Assert.True(false); + aTimer.Stop(); + var e = DateTime.Now; + var diff = s - e; + output.WriteLine("Diff time ", diff); + Assert.True(true); } } } \ No newline at end of file From 97cc4369bdaf4d54a97bbf8b47def85e8a367e05 Mon Sep 17 00:00:00 2001 From: Im_Alpha Date: Tue, 14 Dec 2021 13:33:23 -0800 Subject: [PATCH 5/7] cleaned solution --- .../TeamHobby.UserManagement.xTests.csproj | 5 +++++ Source Code/main/Controller.cs | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj index 9f77f5f..ef2ea1d 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/TeamHobby.UserManagement.xTests.csproj @@ -20,4 +20,9 @@ + + + + + diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs index d4dcfd0..1d74a58 100644 --- a/Source Code/main/Controller.cs +++ b/Source Code/main/Controller.cs @@ -82,15 +82,16 @@ namespace TeamHobby.HobbyProjectGenerator.Main // Create UserAccount class UserAccount user = new UserAccount(username, password, TimeStamp); - + // Call user object and wait for return string string isLogin = manager.CreateUserRecord(user, datasource); - + // If login is not incorrect and user is returning to login menu if (isLogin != "Access Denied: Unauthorized\n") { Console.WriteLine("Returning to login...\n"); Console.WriteLine("-------------------------------------\n"); } + // If login is incorrect else { Console.WriteLine("******Access Denied: Unauthorized******"); From e012dde28c7e1615f158050e9003c5affc765ada Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 14:43:50 -0800 Subject: [PATCH 6/7] Add single and bulk tests --- .../UnitTest1.cs | 117 ++++++++++++++---- 1 file changed, 90 insertions(+), 27 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index eca9743..9128ac4 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -2,6 +2,8 @@ using System; using Xunit; using Xunit.Abstractions; using System.Threading; +using TeamHobby.HobbyProjectGenerator.UserManagement; +using TeamHobby.HobbyProjectGenerator.DataAccess; namespace TeamHobby.UserManagement.xTests { @@ -9,39 +11,100 @@ namespace TeamHobby.UserManagement.xTests { ITestOutputHelper output; - public Example(ITestOutputHelper output) + public UnitTest1(ITestOutputHelper output) { this.output = output; - } + }/* [Fact] public void SingleOperationinFiveSec() { - DateTime start = DateTime.Now; - Thread.Sleep(5000); - // create a file - DateTime end = DateTime.Now; - TimeSpan timeSpan = (end - start); - var sec = timeSpan.TotalSeconds; - //throw new Exception(sec.ToString()); - if (sec > 1) - { - throw new Exception("Greater than 5 seconds"); - } - throw new Exception("Less than 5 seconds"); - //output.WriteLine("check"); - //output.WriteLine("Elapsed time is {0} ms", timeSpan.TotalSeconds); - - var s = DateTime.Now; - output.WriteLine(s); - output.WriteLine("Time is ", DateTime.Now); - aTimer.Start(); + // Arrange + DateTime sTime = DateTime.Now; + var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime); + var serviceTest = new AccountService(); + string dbType = "sql"; + RDSFactory dbFactory = new RDSFactory(); - Assert.True(false); - aTimer.Stop(); - var e = DateTime.Now; - var diff = s - e; - output.WriteLine("Diff time ", diff); - Assert.True(true); + + // Testing Data Access Layer + string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=hobby;" + + "OPTION=3"; + IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // Act + // Create a file + serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource); + DateTime eTime = DateTime.Now; + TimeSpan timeDiff = (eTime - sTime); + var sec = timeDiff.TotalSeconds; + + + // Assert + if (sec > 5) + { + Assert.False(false); + output.WriteLine("Greater than 5 seconds"); + + } + else + { + Assert.True(true); + output.WriteLine("Less than 5 seconds"); + } } + */ + [Fact] + public void BulkOperationforSixty() + { + // Arrange + DateTime sTime = DateTime.Now; + + var serviceTest = new AccountService(); + string dbType = "sql"; + RDSFactory dbFactory = new RDSFactory(); + + + // Testing Data Access Layer + string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + + "TCPIP=1;" + + "SERVER=localhost;" + + "DATABASE=hobby;" + + "UID=root;" + + "PASSWORD=hobby;" + + "OPTION=3"; + IDataSource datasource = dbFactory.getDataSource(dbType, dbInfo); + + // Act + // Create a file + for (int i = 0; i < 10000; i++) + { + var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime); + serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource); + } + + DateTime eTime = DateTime.Now; + TimeSpan timeDiff = (eTime - sTime); + var sec = timeDiff.TotalSeconds; + + + // Assert + if (sec > 60) + { + Assert.False(false); + output.WriteLine("Greater than 60 seconds"); + + } + else + { + Assert.True(true); + output.WriteLine("Less than 60 seconds"); + } + } + } } \ No newline at end of file From 6bf376802d55500add41f60806e3a336682859f1 Mon Sep 17 00:00:00 2001 From: Rifat Hasan Date: Tue, 14 Dec 2021 15:15:40 -0800 Subject: [PATCH 7/7] Add correct failure case --- .../UnitTest1.cs | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs index 9128ac4..60baa67 100644 --- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs +++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs @@ -14,7 +14,7 @@ namespace TeamHobby.UserManagement.xTests public UnitTest1(ITestOutputHelper output) { this.output = output; - }/* + } [Fact] public void SingleOperationinFiveSec() { @@ -25,7 +25,6 @@ namespace TeamHobby.UserManagement.xTests string dbType = "sql"; RDSFactory dbFactory = new RDSFactory(); - // Testing Data Access Layer string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" + "TCPIP=1;" + @@ -43,21 +42,19 @@ namespace TeamHobby.UserManagement.xTests TimeSpan timeDiff = (eTime - sTime); var sec = timeDiff.TotalSeconds; - // Assert if (sec > 5) - { - Assert.False(false); - output.WriteLine("Greater than 5 seconds"); - + { + output.WriteLine("Single Operation was unsuccessful"); + Assert.False(true); } else { Assert.True(true); - output.WriteLine("Less than 5 seconds"); + output.WriteLine("Single Operation was successful"); } } - */ + [Fact] public void BulkOperationforSixty() { @@ -95,16 +92,14 @@ namespace TeamHobby.UserManagement.xTests // Assert if (sec > 60) { - Assert.False(false); - output.WriteLine("Greater than 60 seconds"); - + output.WriteLine("Bulk Operation was unsuccessful"); + Assert.False(true); } else { Assert.True(true); - output.WriteLine("Less than 60 seconds"); + output.WriteLine("Bulk Operation was successful"); } } - } } \ No newline at end of file