Moved API and DB methods to interfaces in order to leverage Dependency Injection, disolved APICaller class, including functionality in several other functions, included Single Load Lock information into Production Passdown report, changed persistant data file to json instead of xml, and adjusted persistant data file to include a week's worth of data instead of a single day.

This commit is contained in:
Daniel Wathen
2022-12-02 14:41:19 -07:00
parent e9c071c8f7
commit 740896adf0
31 changed files with 857 additions and 549 deletions

View File

@ -6,55 +6,39 @@ namespace ReportingServices.Test
public class UnitTest1
{
[TestMethod]
public void CheckAPIIsNotNull()
public void CheckShortDateWithPassedInDate()
{
// Arrange
APICaller apiCaller = new APICaller();
string date = DateTime.Now.ToString("yyyy-M-d") + " 0:0:0";
// Act
apiCaller.CallAllAPIs();
string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), false);
// Assert
Assert.IsNotNull(apiCaller);
Assert.AreEqual(date, callerDate);
}
[TestMethod]
public void CheckFullDateWithPassedInDate()
{
// Arrange
string date = DateTime.Now.ToString("yyyy-M-d HH:mm:ss");
// Act
string callerDate = APIHelperFunctions.GetDateTimeAsAPIString(DateTime.Now.ToString(), true);
// Assert
Assert.AreEqual(date, callerDate);
}
[TestMethod]
public void CheckStartDateForWeekNow()
{
// Arrange
APICaller apiCaller = new APICaller();
string date = DetermineDate();
// Act
string callerDate = apiCaller.DetermineStartDate();
// Assert
Assert.AreEqual(date, callerDate);
}
[TestMethod]
public void CheckStartDateForWeekWednesday()
{
// Arrange
APICaller apiCaller = new APICaller();
string date = "2022-11-21%200%3A0%3A0";
// Act
string callerDate = apiCaller.DetermineStartDate("11/23/2022");
// Assert
Assert.AreEqual(date, callerDate);
}
[TestMethod]
public void CheckStartDateForWeekMonday()
{
// Arrange
APICaller apiCaller = new APICaller();
string date = "2022-11-14%200%3A0%3A0";
// Act
string callerDate = apiCaller.DetermineStartDate("11/21/2022");
string callerDate = APIHelperFunctions.GetBeginningOfWeekAsAPIString();
// Assert
Assert.AreEqual(date, callerDate);
@ -64,11 +48,10 @@ namespace ReportingServices.Test
public void CheckStartDateForDayPassedInAndHoursAdded()
{
// Arrange
APICaller apiCaller = new APICaller();
string date = "2022-11-23%200%3A0%3A0";
string date = "2022-11-23 0:0:0";
// Act
string callerDate = apiCaller.DetermineStartDate("11/23/2022 12:30 PM", 12.5f);
string callerDate = APIHelperFunctions.GetDateWithOffsetAsAPIString("11/23/2022 12:30 PM", -12.5f);
// Assert
Assert.AreEqual(date, callerDate);
@ -79,27 +62,27 @@ namespace ReportingServices.Test
DateTime date = DateTime.Now;
if (date.DayOfWeek == DayOfWeek.Monday)
return date.Year + "-" + date.Month + "-" + (date.Day - 7) + "%200%3A0%3A0";
date = date.AddDays(-7);
if (date.DayOfWeek == DayOfWeek.Tuesday)
return date.Year + "-" + date.Month + "-" + (date.Day - 1) + "%200%3A0%3A0";
date = date.AddDays(-1);
if (date.DayOfWeek == DayOfWeek.Wednesday)
return date.Year + "-" + date.Month + "-" + (date.Day - 2) + "%200%3A0%3A0";
date = date.AddDays(-2);
if (date.DayOfWeek == DayOfWeek.Thursday)
return date.Year + "-" + date.Month + "-" + (date.Day - 3) + "%200%3A0%3A0";
date = date.AddDays(-3);
if (date.DayOfWeek == DayOfWeek.Friday)
return date.Year + "-" + date.Month + "-" + (date.Day - 4) + "%200%3A0%3A0";
date = date.AddDays(-4);
if (date.DayOfWeek == DayOfWeek.Saturday)
return date.Year + "-" + date.Month + "-" + (date.Day - 5) + "%200%3A0%3A0";
date = date.AddDays(-5);
if (date.DayOfWeek == DayOfWeek.Sunday)
return date.Year + "-" + date.Month + "-" + (date.Day - 6) + "%200%3A0%3A0";
date = date.AddDays(-6);
return "";
return date.Year + "-" + date.Month + "-" + date.Day + " 0:0:0"; ;
}
}
}