adjusted files to build menu and start testing

This commit is contained in:
Im_Alpha 2021-12-13 21:41:27 -08:00
parent ca51159bc6
commit 487138890a
15 changed files with 119 additions and 64 deletions

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -14,3 +14,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -13,3 +13,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Contracts
}
}
}
*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -19,3 +19,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
}
*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
@ -21,4 +21,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
}*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -18,3 +18,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging.Implementations
}
}
}
*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
@ -15,4 +15,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
}
}*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
namespace TeamHobby.HobbyProjectGenerator.Logging
{
@ -35,4 +35,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
}
}*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -28,3 +28,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
*/

View File

@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -42,3 +42,4 @@ namespace TeamHobby.HobbyProjectGenerator.Logging
}
}
*/

View File

@ -171,7 +171,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
Console.WriteLine("");
// Closing the connection
sqlDS.getConnection().Close();
sqlDS.GetConnection().Close();
if (checkSql == "Admin")
{
@ -204,12 +204,12 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
AccountService accountService = new AccountService();
// Create credentials object for new inptus
GetCredentials newCredentials = new GetCredentials();
// Print User Management menu
ui.UserManagementMenu(user.username);
// Create bool object for menu loop
bool menuLoop = true;
// Create loop for menu
while (menuLoop is true) {
// Print User Management menu
ui.UserManagementMenu(user.username);
// Get user choice
int menuChoice = Convert.ToInt32(Console.ReadLine());
// Complete the appropriate action
@ -224,8 +224,17 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
newCredentials.GetPassword(), newCredentials.GetEmail(),
newCredentials.GetRole(), DateTime.UtcNow);
accountService.CreateUserRecord(newUser,user.username, dbSource);
break;
bool accountValid = accountService.CreateUserRecord(newUser,user.username, dbSource);
if (accountValid is true)
{
Console.WriteLine("Account created Successfully");
break;
}
else
{
return "Database Timed out";
}
//break;
// Edit account
case 2:
/* UserAccount newEditUser = new UserAccount(newCredentials.GetUserName(),
@ -257,7 +266,8 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
case 7:
break;
default:
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n" +
"------------------------------------\n\n");
break;
}
}

View File

@ -20,7 +20,10 @@ 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}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.ArchiveTests", "..\TeamHobby.HobbyProjectGenerator.ArchiveTests\TeamHobby.HobbyProjectGenerator.ArchiveTests.csproj", "{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TeamHobby.UserManagement.xTests", "TeamHobby.UserManagement.xTests\TeamHobby.UserManagement.xTests.csproj", "{6D575AF1-C138-44C5-B701-5AEC4ACEAA7A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -30,14 +33,6 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.ActiveCfg = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Debug|x86.Build.0 = Debug|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|Any CPU.Build.0 = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.ActiveCfg = Release|Any CPU
{C75B6909-FD9E-4382-94B6-7CA2CE371C9A}.Release|x86.Build.0 = Release|Any CPU
{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
@ -61,7 +56,6 @@ Global
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.ActiveCfg = Release|Any CPU
{30C7EBF3-3957-46E5-86C1-C13356841ECA}.Release|x86.Build.0 = Release|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B88ED0D9-72E2-4245-BD8F-856FF42E500C}.Debug|Any CPU.Build.0 = 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}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -83,7 +77,6 @@ Global
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.ActiveCfg = Release|Any CPU
{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}.Release|x86.Build.0 = Release|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C0494115-838E-43A3-8896-133E5D1E874A}.Debug|Any CPU.Build.0 = 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}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -107,9 +100,20 @@ Global
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.ActiveCfg = Release|Any CPU
{CA8D11CF-807C-4C90-A529-0371F73518F6}.Release|x86.Build.0 = Release|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.Build.0 = 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|Any CPU.Build.0 = 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}.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

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,13 @@
using Xunit;
namespace TeamHobby.UserManagement.xTests
{
public class UnitTest1
{
[Fact]
public void Test1()
{
}
}
}

View File

@ -2,7 +2,6 @@
using System.Data.Odbc;
using TeamHobby.HobbyProjectGenerator.Archive;
using TeamHobby.HobbyProjectGenerator.DataAccess;
using TeamHobby.HobbyProjectGenerator.Logging;
using TeamHobby.HobbyProjectGenerator.UserManagement;
namespace TeamHobby.HobbyProjectGenerator.Main
@ -39,9 +38,11 @@ namespace TeamHobby.HobbyProjectGenerator.Main
// Creating the Factory class
// Logger log = new Logger();
//Logger.PrintTest();
//GetCredentials credentials = new GetCredentials();
//string? username = credentials.GetUserName();
//string? password = credentials.GetPassword();
// Admin login
GetCredentials credentials = new GetCredentials();
string? username = credentials.GetUserName();
string? password = credentials.GetPassword();
//Console.WriteLine(value: $"username is {username}\npassword is {password}");
@ -60,20 +61,14 @@ namespace TeamHobby.HobbyProjectGenerator.Main
"UID=root;" +
"PASSWORD=Teamhobby;" +
"OPTION=3";
IDataSource<string> datasource = factory.getDataSource(dbType, dbInfo);
"PORT=3306;";
"OPTION=3";
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
// Create manager class from UserManagement
SystemAccountManager manager = new SystemAccountManager();
// Admin Sign in
/* // Admin Sign in
GetCredentials credentials = new GetCredentials();
string? username = credentials.GetUserName();
string? password = credentials.GetPassword();
string? password = credentials.GetPassword();*/
// Get time of login attempt
DateTime TimeStamp = DateTime.UtcNow;
@ -242,8 +237,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
{
MainMenu = false;
};*/
//}
}
}
}
}

View File

@ -1,23 +1,3 @@
create table users
(
UserName varchar(50) charset utf8mb3 not null,
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,
constraint userRole_fk foreign key (Role) references roles (Role),
constraint user_pk primary key (UserName)
);
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', 'ApproveDar', 'Admin', 1, 'Jacob', '2021-12-13 04:29:55', null);
create table roles
(
RoleID int not null,
@ -28,6 +8,31 @@ create table roles
primary key (Role)
);
create table users
(
UserName varchar(50) charset utf8mb3 not null
primary key,
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, 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);
INSERT INTO hobby.roles (Role, CreatedBy, CreatedDate) VALUES
('Admin', 'Jacob', '2021-12-13 03:25:14'),
('regular', 'Colin', '2021-12-13 03:25:14');