Changed Removed Entries to throw an Error

Tested the clean up sequence for Manager
This commit is contained in:
Lunastra 2021-12-13 20:50:24 -08:00
parent d8bf615b02
commit dfb32b0e26
4 changed files with 81 additions and 37 deletions

View File

@ -135,6 +135,68 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
}
// [Test Method]
public void IsProcessFlowCompleted(IDataSource<string> sqlDAO)
{
// Arrange
ArchiveManager archive = new ArchiveManager(sqlDAO);
// Act
// Testing archive Manager
int i = -10;
while (i < 20)
{
DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0);
//Console.WriteLine("Testing first of month: {0}", date1.ToString("dd"));
//string currentDate = DateTime.Now.ToString("dd");
//string currentTime = DateTime.Now.ToString("T");
string currentTime = "00:00:00 AM";
string currentDate = i.ToString();
if (i == 1)
{
currentDate = date1.ToString("dd");
//ArchiveManager archive = new ArchiveManager(sqlDAO);
//archive.Controller();
}
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
Console.WriteLine("Archiving process Start");
//ArchiveManager archive = new ArchiveManager(sqlDAO);
archive.Controller();
}
i++;
}
}
public void IsCleaningUpCompleted(IDataSource<string> sqlDAO)
{
//Arrange
ArchiveManager archive = new ArchiveManager(sqlDAO);
bool actualVal = false;
bool expectedVal = false;
// Act
actualVal = archive.Controller();
// Assert
//bool result = !(actualVal && expectedVal);
if (expectedVal == actualVal)
{
Console.WriteLine("Expected: {0}, Actual: {1}. Error handle correctly", expectedVal, actualVal);
}
else
{
Console.WriteLine("Expected: {0}, Actual: {1}. Error handle incorrectly", expectedVal, actualVal);
}
}
public static void Main(string[] args)
{
string dbInfo = "DRIVER={MariaDB ODBC 3.1 Driver};" +
@ -163,35 +225,12 @@ namespace TeamHobby.HobbyProjectGenerator.ArchiveTests
Console.WriteLine("-----------------");
Console.WriteLine("");
// Testing archive Manager
int i = -10;
while (i < 20)
{
DateTime date1 = new DateTime(2021, 12, 1, 0, 0, 0);
//Console.WriteLine("Testing first of month: {0}", date1.ToString("dd"));
//string currentDate = DateTime.Now.ToString("dd");
//string currentTime = DateTime.Now.ToString("T");
string currentTime= "00:00:00 AM";
string currentDate = i.ToString();
if (i == 1)
{
currentDate = date1.ToString("dd");
//ArchiveManager archive = new ArchiveManager(sqlDAO);
//archive.Controller();
}
//Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
Console.WriteLine("Current date: {0}, Current Time: {1}", currentDate, currentTime);
if (String.Equals(currentDate, "01") && String.Equals(currentTime, "00:00:00 AM"))
{
Console.WriteLine("Archiving process Start");
ArchiveManager archive = new ArchiveManager(sqlDAO);
archive.Controller();
}
i++;
}
// Testing clean up sequence
//test.IsCleaningUpCompleted(sqlDAO);
//Console.WriteLine("-----------------");
//Console.WriteLine("");
}

View File

@ -238,14 +238,12 @@ namespace TeamHobby.HobbyProjectGenerator.DataAccess
string sqlCmd = "DELETE FROM log WHERE DATEDIFF(current_timestamp, log.LtimeStamp) > 30";
try{
DeleteData(sqlCmd);
return true;
}
catch {
Console.WriteLine("Eeep! an error in Remove Entries, not to worry, will be handled higher up the call stack");
throw;
}
if (DeleteData(sqlCmd) == false)
{
throw new Exception("Error in removing entries,not to worry, will be handled higher up the call stack");
};
return true;
}
//public Object ReadPreparedStmt(string table){

View File

@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.Main", "..\TeamHo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamHobby.HobbyProjectGenerator.DataAccess", "..\TeamHobby.HobbyProjectGenerator.DataAccess\TeamHobby.HobbyProjectGenerator.DataAccess.csproj", "{AA48A66C-FA36-4AF9-A782-CEC22838EB8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTEst1", "..\UnitTEst1\UnitTEst1.csproj", "{139F060F-EE24-4C34-A3AD-148B0C024EF9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -54,6 +56,10 @@ Global
{C5EBD1F8-C806-4BF9-B2D7-8876072630FD}.Debug|Any CPU.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
{139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{139F060F-EE24-4C34-A3AD-148B0C024EF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{139F060F-EE24-4C34-A3AD-148B0C024EF9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -56,6 +56,7 @@ namespace TeamHobby.HobbyProjectGenerator.Main
reader = (OdbcDataReader)result;
}
// [Logname, loglevel, date, time, ...]
Console.WriteLine("Reading from the database");
while (reader.Read())