diff --git a/ReportingServices.API/Models/AppSettings.cs b/ReportingServices.API/Models/AppSettings.cs index 1905f1c..9c8f96a 100644 --- a/ReportingServices.API/Models/AppSettings.cs +++ b/ReportingServices.API/Models/AppSettings.cs @@ -10,8 +10,7 @@ public record AppSettings(string BuildNumber, bool IsDevelopment, bool IsStaging, string MonAResource, - string MonASite, - string URLs) + string MonASite) { public override string ToString() diff --git a/ReportingServices.API/Models/Binder/AppSettings.cs b/ReportingServices.API/Models/Binder/AppSettings.cs index 111f39f..8623e6f 100644 --- a/ReportingServices.API/Models/Binder/AppSettings.cs +++ b/ReportingServices.API/Models/Binder/AppSettings.cs @@ -17,7 +17,6 @@ public class AppSettings [Display(Name = "Is Staging"), Required] public bool? IsStaging { get; set; } [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } [Display(Name = "MonA Site"), Required] public string MonASite { get; set; } - [Display(Name = "URLs"), Required] public string URLs { get; set; } #nullable enable @@ -50,8 +49,6 @@ public class AppSettings throw new NullReferenceException(nameof(MonAResource)); if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite)); - if (appSettings.URLs is null) - throw new NullReferenceException(nameof(URLs)); result = new( appSettings.BuildNumber, appSettings.Company, @@ -61,8 +58,7 @@ public class AppSettings appSettings.IsDevelopment.Value, appSettings.IsStaging.Value, appSettings.MonAResource, - appSettings.MonASite, - appSettings.URLs); + appSettings.MonASite); return result; } diff --git a/ReportingServices.API/Program.cs b/ReportingServices.API/Program.cs index 80ceb00..737b18c 100644 --- a/ReportingServices.API/Program.cs +++ b/ReportingServices.API/Program.cs @@ -2,7 +2,9 @@ using ReportingServices.API.Models; using ReportingServices.Shared.Repositories; using Serilog; -internal class Program +namespace ReportingServices.API; + +public class Program { private static void Main(string[] args) { @@ -10,7 +12,7 @@ internal class Program WebApplicationBuilder builder = WebApplication.CreateBuilder(args); _ = builder.Configuration.AddUserSecrets(); - AppSettings appSettings = ReportingServices.API.Models.Binder.AppSettings.Get(builder.Configuration); + AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); Environment.SetEnvironmentVariable("workingDirectory", appSettings.LoggingDirectory); _ = loggerConfiguration.ReadFrom.Configuration(builder.Configuration); _ = builder.Host.UseSerilog(); diff --git a/ReportingServices.Test/APIHelperTester.cs b/ReportingServices.Test/APIHelperTester.cs index bcaf76e..07ef2df 100644 --- a/ReportingServices.Test/APIHelperTester.cs +++ b/ReportingServices.Test/APIHelperTester.cs @@ -1,10 +1,125 @@ +using Microsoft.AspNetCore.Mvc.Testing; using ReportingServices.Shared.HelperClasses; +using ReportingServices.Shared.Models.PlanningReport; +using ReportingServices.Shared.Models.ProductionReport; +using Serilog; +using System.Net.Http.Json; namespace ReportingServices.Test; [TestClass] public class APIHelperTester { + +#pragma warning disable CS8618 + + private static ILogger _Logger; + private static string _ControllerName; + private static TestContext _TestContext; + private static WebApplicationFactory _WebApplicationFactory; + +#pragma warning restore + + [ClassInitialize] + public static void ClassInitAsync(TestContext testContext) + { + _TestContext = testContext; + _Logger = Log.ForContext(); + _WebApplicationFactory = new WebApplicationFactory(); + _ControllerName = nameof(API.Controllers.ScrapeDBController)[..^10]; + } + + [TestMethod] + public async Task ReactorOuts() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + DateTime endDate = DateTime.Now; + DateTime startDate = endDate.AddHours(-24); + YieldInformation? result = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/ReactorOuts/?startDate={startDate}&endDate={endDate}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task PSNWO() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + DateTime endDate = DateTime.Now; + DateTime startDate = endDate.AddHours(-3); + List? result = await httpClient.GetFromJsonAsync>($"api/{_ControllerName}/PSNWO/?startDate={startDate}&endDate={endDate}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task PartChanges() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + DateTime endDate = DateTime.Now; + DateTime startDate = endDate.AddHours(-3); + int? result = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/PartChanges/?startDate={startDate}&endDate={endDate}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task Targets() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + QuarterlyTargets? result = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/Targets"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task Reactors() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + List? result = await httpClient.GetFromJsonAsync>($"api/{_ControllerName}/Reactors"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task RDS() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + DateTime date = DateTime.Now; + List? result = await httpClient.GetFromJsonAsync>($"api/{_ControllerName}/RDS/?date={date}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task ReactorEvents() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string reactorNumber = "37"; + DateTime endDate = DateTime.Now; + DateTime startDate = endDate.AddHours(-3); + List? result = await httpClient.GetFromJsonAsync>($"api/{_ControllerName}/ReactorEvents/?startDate={startDate}&endDate={endDate}&reactorNumber={reactorNumber}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + + [TestMethod] + public async Task ToolEvents() + { + HttpClient httpClient = _WebApplicationFactory.CreateClient(); + _Logger.Information("Starting Web Application"); + string toolID = "37"; + ToolEvent? result = await httpClient.GetFromJsonAsync($"api/{_ControllerName}/ToolEvents/?toolID={toolID}"); + Assert.IsNotNull(result); + _Logger.Information($"{_TestContext?.TestName} completed"); + } + [TestMethod] public void CheckShortDateWithPassedInDate() { diff --git a/ReportingServices.Test/ReportingServices.Test.csproj b/ReportingServices.Test/ReportingServices.Test.csproj index f485b7e..b290a87 100644 --- a/ReportingServices.Test/ReportingServices.Test.csproj +++ b/ReportingServices.Test/ReportingServices.Test.csproj @@ -19,6 +19,7 @@ + diff --git a/ReportingServices.UI/Models/AppSettings.cs b/ReportingServices.UI/Models/AppSettings.cs index dc935f4..0a558b1 100644 --- a/ReportingServices.UI/Models/AppSettings.cs +++ b/ReportingServices.UI/Models/AppSettings.cs @@ -12,8 +12,7 @@ public record AppSettings(string BaseAPIAddress, bool IsStaging, string MonAResource, string MonASite, - string ToolStateOwnerFilePath, - string URLs) + string ToolStateOwnerFilePath) { public override string ToString() diff --git a/ReportingServices.UI/Models/Binder/AppSettings.cs b/ReportingServices.UI/Models/Binder/AppSettings.cs index 1a6a4e7..7e89de9 100644 --- a/ReportingServices.UI/Models/Binder/AppSettings.cs +++ b/ReportingServices.UI/Models/Binder/AppSettings.cs @@ -19,7 +19,6 @@ public class AppSettings [Display(Name = "MonA Resource"), Required] public string MonAResource { get; set; } [Display(Name = "MonA Site"), Required] public string MonASite { get; set; } [Display(Name = "Tool State Owner File Path"), Required] public string ToolStateOwnerFilePath { get; set; } - [Display(Name = "URLs"), Required] public string URLs { get; set; } #nullable enable @@ -54,8 +53,6 @@ public class AppSettings throw new NullReferenceException(nameof(MonAResource)); if (appSettings.MonASite is null) throw new NullReferenceException(nameof(MonASite)); - if (appSettings.URLs is null) - throw new NullReferenceException(nameof(URLs)); if (appSettings.ToolStateOwnerFilePath is null) throw new NullReferenceException(nameof(ToolStateOwnerFilePath)); result = new( @@ -69,8 +66,7 @@ public class AppSettings appSettings.IsStaging.Value, appSettings.MonAResource, appSettings.MonASite, - appSettings.ToolStateOwnerFilePath, - appSettings.URLs); + appSettings.ToolStateOwnerFilePath); return result; } diff --git a/ReportingServices.UI/Program.cs b/ReportingServices.UI/Program.cs index d6f1740..8ce49c4 100644 --- a/ReportingServices.UI/Program.cs +++ b/ReportingServices.UI/Program.cs @@ -1,7 +1,9 @@ using ReportingServices.UI.Models; using Serilog; -internal class Program +namespace ReportingServices.UI; + +public class Program { private static void Main(string[] args) { @@ -9,7 +11,7 @@ internal class Program WebApplicationBuilder builder = WebApplication.CreateBuilder(args); _ = builder.Configuration.AddUserSecrets(); - AppSettings appSettings = ReportingServices.UI.Models.Binder.AppSettings.Get(builder.Configuration); + AppSettings appSettings = Models.Binder.AppSettings.Get(builder.Configuration); Environment.SetEnvironmentVariable("workingDirectory", "D:\\tmp\\logging\\MesaReportingServices\\UI"); _ = loggerConfiguration.ReadFrom.Configuration(builder.Configuration); _ = builder.Host.UseSerilog();