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
diff --git a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
index ba3e00b..70e1f15 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
+++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.HobbyProjectGenerator.sln
@@ -17,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}"
@@ -42,7 +38,6 @@ Global
{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
{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
@@ -69,6 +64,7 @@ Global
{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
{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Debug|Any CPU.ActiveCfg = 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
EndGlobalSection
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/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs
index 4f483ad..60baa67 100644
--- a/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs
+++ b/Source Code/TeamHobby.HobbyProjectGenerator/TeamHobby.UserManagement.xTests/UnitTest1.cs
@@ -1,13 +1,105 @@
+using System;
using Xunit;
+using Xunit.Abstractions;
+using System.Threading;
+using TeamHobby.HobbyProjectGenerator.UserManagement;
+using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.UserManagement.xTests
{
public class UnitTest1
{
- [Fact]
- public void Test1()
+
+ ITestOutputHelper output;
+ public UnitTest1(ITestOutputHelper output)
{
+ this.output = output;
+ }
+ [Fact]
+ public void SingleOperationinFiveSec()
+ {
+ // 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();
+ // 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)
+ {
+ output.WriteLine("Single Operation was unsuccessful");
+ Assert.False(true);
+ }
+ else
+ {
+ Assert.True(true);
+ output.WriteLine("Single Operation was successful");
+ }
+ }
+
+ [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)
+ {
+ output.WriteLine("Bulk Operation was unsuccessful");
+ Assert.False(true);
+ }
+ else
+ {
+ Assert.True(true);
+ output.WriteLine("Bulk Operation was successful");
+ }
}
}
}
\ No newline at end of file
diff --git a/Source Code/main/Controller.cs b/Source Code/main/Controller.cs
index 385a928..1d74a58 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 " +
@@ -68,7 +69,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//{
string currentDate = DateTime.Now.ToString("dd");
string currentTime = DateTime.Now.ToString("T");
- Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
+ //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);
@@ -81,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******");
@@ -126,8 +128,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');";
@@ -143,7 +143,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 @@
-
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';