First Commit
This commit is contained in:
27
ReportingServices.Test/ReportingServices.Test.csproj
Normal file
27
ReportingServices.Test/ReportingServices.Test.csproj
Normal file
@ -0,0 +1,27 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.2.8" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.2.8" />
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ReportingServices\ReportingServices.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="JSON_Testing\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
107
ReportingServices.Test/UnitTest1.cs
Normal file
107
ReportingServices.Test/UnitTest1.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using ReportingServices.HelperClasses;
|
||||
using ReportingServices.ReportingObjects;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ReportingServices.Test
|
||||
{
|
||||
[TestClass]
|
||||
public class UnitTest1
|
||||
{
|
||||
[TestMethod]
|
||||
public void CheckAPIIsNotNull()
|
||||
{
|
||||
// Arrange
|
||||
APICaller apiCaller = new APICaller();
|
||||
|
||||
// Act
|
||||
apiCaller.CallAllAPIs();
|
||||
|
||||
// Assert
|
||||
Assert.IsNotNull(apiCaller);
|
||||
}
|
||||
|
||||
[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");
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(date, callerDate);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CheckStartDateForDayPassedInAndHoursAdded()
|
||||
{
|
||||
// Arrange
|
||||
APICaller apiCaller = new APICaller();
|
||||
string date = "2022-11-23%200%3A0%3A0";
|
||||
|
||||
// Act
|
||||
string callerDate = apiCaller.DetermineStartDate("11/23/2022 12:30 PM", 12.5f);
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(date, callerDate);
|
||||
}
|
||||
|
||||
private string DetermineDate()
|
||||
{
|
||||
DateTime date = DateTime.Now;
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Monday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 7) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Tuesday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 1) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Wednesday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 2) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Thursday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 3) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Friday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 4) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Saturday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 5) + "%200%3A0%3A0";
|
||||
|
||||
if (date.DayOfWeek == DayOfWeek.Sunday)
|
||||
return date.Year + "-" + date.Month + "-" + (date.Day - 6) + "%200%3A0%3A0";
|
||||
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
1
ReportingServices.Test/Usings.cs
Normal file
1
ReportingServices.Test/Usings.cs
Normal file
@ -0,0 +1 @@
|
||||
global using Microsoft.VisualStudio.TestTools.UnitTesting;
|
Reference in New Issue
Block a user