Merge branch 'Jacobs-Branch'

This commit is contained in:
Im_Alpha 2021-12-14 15:27:10 -08:00
commit 4cf16cce93
8 changed files with 138 additions and 54 deletions

View File

@ -286,7 +286,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
} }
else else
{ {
return "Database Timed out"; return "User does not exist";
} }
break; break;
// Enable account // Enable account
@ -301,7 +301,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
} }
else else
{ {
return "Database Timed out"; return "User does not exist";
} }
break; break;
// View logs // View logs

View File

@ -17,12 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGener
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
EndProject 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.UserManagement", "..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj", "{2E7193B8-86B6-48DA-9671-CD84615A5F5D}"
EndProject 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}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}" 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.ActiveCfg = Release|Any CPU
{5C5A44B4-EC3C-44F2-8F39-F917F8ED932F}.Release|Any CPU.Build.0 = 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.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.ActiveCfg = Release|Any CPU
{75DED6C2-D404-4E71-A58B-0F616DB5C062}.Release|Any CPU.Build.0 = 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 {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.ActiveCfg = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Release|Any CPU.Build.0 = 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.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.ActiveCfg = Release|Any CPU
{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU {6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection

View File

@ -20,4 +20,9 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,13 +1,105 @@
using System;
using Xunit; using Xunit;
using Xunit.Abstractions;
using System.Threading;
using TeamHobby.HobbyProjectGenerator.UserManagement;
using TeamHobby.HobbyProjectGenerator.DataAccess;
namespace TeamHobby.UserManagement.xTests namespace TeamHobby.UserManagement.xTests
{ {
public class UnitTest1 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<string> 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<string> 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");
}
} }
} }
} }

View File

@ -29,6 +29,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Loop Admin login // Loop Admin login
while (mainMenu is true) while (mainMenu is true)
{ {
// Admin Sign in // Admin Sign in
GetCredentials credentials = new GetCredentials(); GetCredentials credentials = new GetCredentials();
Console.WriteLine("\nPlease Enter Admin Credentials " + Console.WriteLine("\nPlease Enter Admin Credentials " +
@ -68,7 +69,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//{ //{
string currentDate = DateTime.Now.ToString("dd"); string currentDate = DateTime.Now.ToString("dd");
string currentTime = DateTime.Now.ToString("T"); 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")) if (String.Equals(currentDate, "1") && String.Equals(currentTime, "00:00:00 AM"))
{ {
ArchiveManager archive = new ArchiveManager(datasource); ArchiveManager archive = new ArchiveManager(datasource);
@ -81,15 +82,16 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Create UserAccount class // Create UserAccount class
UserAccount user = new UserAccount(username, password, TimeStamp); UserAccount user = new UserAccount(username, password, TimeStamp);
// Call user object and wait for return string
string isLogin = manager.CreateUserRecord(user, datasource); string isLogin = manager.CreateUserRecord(user, datasource);
// If login is not incorrect and user is returning to login menu
if (isLogin != "Access Denied: Unauthorized\n") if (isLogin != "Access Denied: Unauthorized\n")
{ {
Console.WriteLine("Returning to login...\n"); Console.WriteLine("Returning to login...\n");
Console.WriteLine("-------------------------------------\n"); Console.WriteLine("-------------------------------------\n");
} }
// If login is incorrect
else else
{ {
Console.WriteLine("******Access Denied: Unauthorized******"); Console.WriteLine("******Access Denied: Unauthorized******");
@ -126,8 +128,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//sqlDS.RemoveEntries(); //sqlDS.RemoveEntries();
// 2.Inserting Data into the database: // 2.Inserting Data into the database:
//string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " + //string sqlWrite = "INSERT into log(lvname, catname, userop, logmessage) values " +
// "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');"; // "('Info', 'View', 'Testing DAL stuffs', 'new DAL method tested');";
@ -143,7 +143,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
//Console.WriteLine("Writing completed. "); //Console.WriteLine("Writing completed. ");
} }
} }
}
} }

View File

@ -16,7 +16,6 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Archive\TeamHobby.HobbyProjectGenerator.Archive.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.Logging\TeamHobby.HobbyProjectGenerator.Logging.csproj" />
<ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" /> <ProjectReference Include="..\TeamHobby.HobbyProjectGenerator.UserManagement\TeamHobby.HobbyProjectGenerator.UserManagement.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -34,4 +34,4 @@ INSERT INTO hobby.users (UserName, Password, Role, IsActive, CreatedBy, CreatedD
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES
('Admin', 'Jacob', '2021-12-13 03:25:14'), ('Admin', 'Jacob', '2021-12-13 03:25:14'),
('regular', 'Colin', '2021-12-13 03:25:14'); ('regular', 'Jacob', '2021-12-13 03:25:14');

View File

@ -2,52 +2,44 @@ create database Hobby;
use 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 create table users
( (
UserName varchar(50) charset utf8mb3 not null UserName varchar(50) charset utf8mb3 not null
primary key, primary key,
Password varchar(50) charset utf8mb3 null, Password varchar(50) charset utf8mb3 not null,
RoleID int auto_increment, Role varchar(50) charset utf8mb3 not null,
IsActive int default 1 null, IsActive int default 1 not null,
CreatedBy varchar(50) charset utf8mb3 null, CreatedBy varchar(50) charset utf8mb3 not null,
CreatedDate datetime null, CreatedDate datetime not null,
constraint users_UserName_uindex Email varchar(50) null,
unique (UserName), constraint users_Email_uindex
constraint users_roles_RoleID_fk unique (Email),
foreign key (RoleID) references roles (RoleID) 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, Role, IsActive, CreatedBy, CreatedDate, Email) VALUES
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Jacob', 'Teamhobby1234', 'SystemCreator', '2021-12-13 03:25:14'); ('Colin ', 'Waffle', 'Admin', 1, 'Jacob', '2021-12-13 04:27:42', null),
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Long', 'Joystick', 'Jacob', '2021-12-13 04:29:57'); ('Danny', 'Spartan', 'Admin', 1, 'Jacob', '2021-12-13 04:29:54', null),
INSERT INTO hobby.users (UserName, Password, CreatedBy, CreatedDate) VALUES ('Rifat', 'ApproveDar', 'Jacob', '2021-12-13 04:29:55'); ('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 INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES
( ('Admin', 'Jacob', '2021-12-13 03:25:14'),
RoleID int auto_increment ('regular', 'Jacob', '2021-12-13 03:25:14');
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', '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_per_table=ON;
-- SET GLOBAL innodb_file_format='Barracuda'; -- SET GLOBAL innodb_file_format='Barracuda';