fixed testing, add archive path to menu
This commit is contained in:
parent
f11ed7d6ad
commit
27080ce36c
@ -121,16 +121,16 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public bool BulkOperation(string signedUser, IDataSource<string> dbSource)
|
public bool BulkOperation(string signedUser, string path, IDataSource<string> dbSource)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get the current directory.
|
// Get the current directory.
|
||||||
string path = Directory.GetCurrentDirectory();
|
//string path = Directory.GetCurrentDirectory();
|
||||||
// Open file reader stream
|
// Open file reader stream
|
||||||
using StreamReader fileRead = new(path + "\\BulkOps\\Bulk.txt"); // path + "\\BulkOps\\{input}"
|
using StreamReader fileRead = new(path); // path + + "\\BulkOps\\Bulk.txt"
|
||||||
// Show location of the file being written
|
// Show location of the file being written
|
||||||
Console.WriteLine(path + "\\BulkOps\\Bulk.txt");
|
//Console.WriteLine(path);
|
||||||
|
|
||||||
// List choices of operations
|
// List choices of operations
|
||||||
List<string> ops = new List<string> {"Create Account", "Edit Account",
|
List<string> ops = new List<string> {"Create Account", "Edit Account",
|
||||||
|
|||||||
@ -313,6 +313,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
|||||||
// Get name of file and update path to correct folder
|
// Get name of file and update path to correct folder
|
||||||
Console.WriteLine("Please input the name of the file:(Example.txt)");
|
Console.WriteLine("Please input the name of the file:(Example.txt)");
|
||||||
string filename = $"{path}\\BulkOps\\{Console.ReadLine()}";
|
string filename = $"{path}\\BulkOps\\{Console.ReadLine()}";
|
||||||
|
//Console.WriteLine(filename)
|
||||||
|
|
||||||
// Get filesize
|
// Get filesize
|
||||||
long fileSize = filename.Length;
|
long fileSize = filename.Length;
|
||||||
@ -334,7 +335,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
|||||||
{
|
{
|
||||||
// Begin bulk operation
|
// Begin bulk operation
|
||||||
Console.WriteLine("Running bulk operation...");
|
Console.WriteLine("Running bulk operation...");
|
||||||
bool bulkReq = bulkOP.BulkOperation(user.username, dbSource);
|
bool bulkReq = bulkOP.BulkOperation(user.username, filename, dbSource);
|
||||||
if (bulkReq is true)
|
if (bulkReq is true)
|
||||||
{
|
{
|
||||||
Console.WriteLine("\nBulk operation complete");
|
Console.WriteLine("\nBulk operation complete");
|
||||||
@ -352,6 +353,7 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
|||||||
break;
|
break;
|
||||||
// View archive
|
// View archive
|
||||||
case 8:
|
case 8:
|
||||||
|
Console.WriteLine("C:/HobbyArchive");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
|
Console.WriteLine("Invalid input.\nPlease enter a valid option.\n");
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using Xunit.Abstractions;
|
|||||||
using System.Threading;
|
using System.Threading;
|
||||||
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
||||||
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace TeamHobby.UserManagement.xTests
|
namespace TeamHobby.UserManagement.xTests
|
||||||
{
|
{
|
||||||
@ -47,7 +48,7 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
if (sec > 5)
|
if (sec > 5)
|
||||||
{
|
{
|
||||||
output.WriteLine("Single Operation was unsuccessful");
|
output.WriteLine("Single Operation was unsuccessful");
|
||||||
Assert.False(true);
|
Assert.True(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -73,7 +74,7 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
"SERVER=localhost;" +
|
"SERVER=localhost;" +
|
||||||
"DATABASE=hobby;" +
|
"DATABASE=hobby;" +
|
||||||
"UID=root;" +
|
"UID=root;" +
|
||||||
"PASSWORD=hobby;" +
|
"PASSWORD=Teamhobby;" +
|
||||||
"OPTION=3";
|
"OPTION=3";
|
||||||
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
@ -89,11 +90,11 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
if (sec > 5)
|
if (sec > 5)
|
||||||
{
|
{
|
||||||
output.WriteLine("Single Operation was unsuccessful");
|
output.WriteLine("Single Operation was unsuccessful");
|
||||||
Assert.False(true);
|
Assert.False(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Assert.True(true);
|
Assert.True(false);
|
||||||
output.WriteLine("Single Operation was successful");
|
output.WriteLine("Single Operation was successful");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,7 +104,7 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
DateTime sTime = DateTime.Now;
|
DateTime sTime = DateTime.Now;
|
||||||
var TestAcc = new UserAccount("newUser", "4567", "email@a.com", "regular", sTime);
|
var TestAcc = new UserAccount("newUserMessage", "4567", "email@a.com", "regular", sTime);
|
||||||
var serviceTest = new AccountService();
|
var serviceTest = new AccountService();
|
||||||
string dbType = "sql";
|
string dbType = "sql";
|
||||||
RDSFactory dbFactory = new RDSFactory();
|
RDSFactory dbFactory = new RDSFactory();
|
||||||
@ -126,12 +127,14 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
var sec = timeDiff.TotalSeconds;
|
var sec = timeDiff.TotalSeconds;
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
if (sec > 0)
|
if (sec > 5)
|
||||||
{
|
{
|
||||||
var message = "Single Operation was unsuccessful";
|
var message = "Single Operation was unsuccessful";
|
||||||
|
Assert.False(true);
|
||||||
output.WriteLine(message);
|
output.WriteLine(message);
|
||||||
if (checkMess)
|
if (checkMess)
|
||||||
{
|
{
|
||||||
|
Assert.False(true);
|
||||||
throw new Exception("Message was not printed");
|
throw new Exception("Message was not printed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,6 +160,7 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
var serviceTest = new AccountService();
|
var serviceTest = new AccountService();
|
||||||
string dbType = "sql";
|
string dbType = "sql";
|
||||||
RDSFactory dbFactory = new RDSFactory();
|
RDSFactory dbFactory = new RDSFactory();
|
||||||
|
string path = Directory.GetCurrentDirectory();
|
||||||
|
|
||||||
|
|
||||||
// Testing Data Access Layer
|
// Testing Data Access Layer
|
||||||
@ -171,11 +175,11 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
|
|
||||||
// Act
|
// Act
|
||||||
// Create a file
|
// Create a file
|
||||||
for (int i = 0; i < 10000; i++)
|
//for (int i = 0; i < 10000; i++)
|
||||||
{
|
//{
|
||||||
var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
|
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
|
||||||
serviceTest.DeleteUserRecord(TestAcc, "Rifat", datasource);
|
serviceTest.BulkOperation("Rifat", path + "\\BulkOps\\Bulk.txt", datasource);
|
||||||
}
|
//}
|
||||||
|
|
||||||
DateTime eTime = DateTime.Now;
|
DateTime eTime = DateTime.Now;
|
||||||
TimeSpan timeDiff = (eTime - sTime);
|
TimeSpan timeDiff = (eTime - sTime);
|
||||||
@ -186,9 +190,11 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
if (sec > 60)
|
if (sec > 60)
|
||||||
{
|
{
|
||||||
var message = "Bulk Operation was unsuccessful";
|
var message = "Bulk Operation was unsuccessful";
|
||||||
|
Assert.True(false);
|
||||||
output.WriteLine(message);
|
output.WriteLine(message);
|
||||||
if (checkMess)
|
if (checkMess)
|
||||||
{
|
{
|
||||||
|
Assert.True(false);
|
||||||
throw new Exception("Message was not printed");
|
throw new Exception("Message was not printed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,6 +220,9 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
var serviceTest = new AccountService();
|
var serviceTest = new AccountService();
|
||||||
string dbType = "sql";
|
string dbType = "sql";
|
||||||
RDSFactory dbFactory = new RDSFactory();
|
RDSFactory dbFactory = new RDSFactory();
|
||||||
|
string dir = Directory.GetCurrentDirectory();
|
||||||
|
string path = dir + "\\BulkOps\\Bulk.txt";
|
||||||
|
output.WriteLine(path);
|
||||||
|
|
||||||
|
|
||||||
// Testing Data Access Layer
|
// Testing Data Access Layer
|
||||||
@ -222,17 +231,17 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
"SERVER=localhost;" +
|
"SERVER=localhost;" +
|
||||||
"DATABASE=hobby;" +
|
"DATABASE=hobby;" +
|
||||||
"UID=root;" +
|
"UID=root;" +
|
||||||
"PASSWORD=hobby;" +
|
"PASSWORD=Teamhobby;" +
|
||||||
"OPTION=3";
|
"OPTION=3";
|
||||||
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
// Create a file
|
// Create a file
|
||||||
for (int i = 0; i < 10000; i++) // Change 10000 to how many accounts you want to test
|
//for (int i = 0; i < 10000; i++)
|
||||||
{
|
//{
|
||||||
var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
|
//var TestAcc = new UserAccount("newUser" + $"{i}", "4567", $"email{i}@a.com", "regular", sTime);
|
||||||
serviceTest.CreateUserRecord(TestAcc, "Rifat", datasource);
|
serviceTest.BulkOperation("Rifat", path, datasource);
|
||||||
}
|
//}
|
||||||
|
|
||||||
DateTime eTime = DateTime.Now;
|
DateTime eTime = DateTime.Now;
|
||||||
TimeSpan timeDiff = (eTime - sTime);
|
TimeSpan timeDiff = (eTime - sTime);
|
||||||
@ -243,7 +252,7 @@ namespace TeamHobby.UserManagement.xTests
|
|||||||
if (sec > 60)
|
if (sec > 60)
|
||||||
{
|
{
|
||||||
output.WriteLine("Bulk Operation was unsuccessful");
|
output.WriteLine("Bulk Operation was unsuccessful");
|
||||||
Assert.False(true);
|
Assert.True(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -29,9 +29,14 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
// Loop Admin login
|
// Loop Admin login
|
||||||
while (mainMenu is true)
|
while (mainMenu is true)
|
||||||
{
|
{
|
||||||
|
// Create credentials object
|
||||||
|
GetCredentials credentials = new GetCredentials();
|
||||||
|
|
||||||
|
// Get DB credentials ***Both values currently hard coded, will update to user input later on.***
|
||||||
|
string dbUserName = "root";
|
||||||
|
string dbPassword = "Teamhobby";
|
||||||
|
|
||||||
// Admin Sign in
|
// Admin Sign in
|
||||||
GetCredentials credentials = new GetCredentials();
|
|
||||||
Console.WriteLine("\nPlease Enter Admin Credentials " +
|
Console.WriteLine("\nPlease Enter Admin Credentials " +
|
||||||
"or enter 0 to exit the machine\n");
|
"or enter 0 to exit the machine\n");
|
||||||
string? username = credentials.GetUserName();
|
string? username = credentials.GetUserName();
|
||||||
@ -56,8 +61,8 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
|||||||
"TCPIP=1;" +
|
"TCPIP=1;" +
|
||||||
"SERVER=localhost;" +
|
"SERVER=localhost;" +
|
||||||
"DATABASE=hobby;" +
|
"DATABASE=hobby;" +
|
||||||
"UID=root;" +
|
$"UID={dbUserName};" +
|
||||||
"PASSWORD=Teamhobby;" +
|
$"PASSWORD={dbPassword};" +
|
||||||
"OPTION=3";
|
"OPTION=3";
|
||||||
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
IDataSource<string> datasource = dbFactory.getDataSource(dbType, dbInfo);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user