Spreading Resistance Profile with ChartJS,
Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
@ -33,10 +33,10 @@
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="3.4.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
|
67
Tests/UnitTestISpreadingResistanceProfileController.cs
Normal file
67
Tests/UnitTestISpreadingResistanceProfileController.cs
Normal file
@ -0,0 +1,67 @@
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using Serilog;
|
||||
|
||||
namespace OI.Metrology.Tests;
|
||||
|
||||
[TestClass]
|
||||
public class UnitTestISpreadingResistanceProfileController
|
||||
{
|
||||
|
||||
#pragma warning disable CS8618
|
||||
|
||||
private static ILogger _Logger;
|
||||
private static string _ControllerName;
|
||||
private static TestContext _TestContext;
|
||||
private static WebApplicationFactory<Server.Program> _WebApplicationFactory;
|
||||
|
||||
#pragma warning restore
|
||||
|
||||
[ClassInitialize]
|
||||
public static void ClassInitAsync(TestContext testContext)
|
||||
{
|
||||
_TestContext = testContext;
|
||||
_Logger = Log.ForContext<UnitTestISpreadingResistanceProfileController>();
|
||||
_WebApplicationFactory = new WebApplicationFactory<Server.Program>();
|
||||
_ControllerName = nameof(Server.ApiControllers.InfinityQSController)[..^10];
|
||||
}
|
||||
|
||||
private static void NonThrowTryCatch()
|
||||
{
|
||||
try
|
||||
{ throw new Exception(); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestControllerName()
|
||||
{
|
||||
_Logger.Information("Starting Web Application");
|
||||
Assert.AreEqual(IInfinityQSController<string>.GetRouteName(), _ControllerName);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetSpreadingResistanceProfileServiceImageBytes()
|
||||
{
|
||||
_Logger.Information("Starting Web Application");
|
||||
string directory = "D:/wwwRoot";
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
string file = Path.Combine(directory, "data.json");
|
||||
if (File.Exists(file))
|
||||
{
|
||||
string json = File.ReadAllText(file);
|
||||
IServiceProvider serviceProvider = _WebApplicationFactory.Services.CreateScope().ServiceProvider;
|
||||
ISpreadingResistanceProfileService spreadingResistanceProfileService = serviceProvider.GetRequiredService<ISpreadingResistanceProfileService>();
|
||||
byte[] bytes = spreadingResistanceProfileService.GetImageBytes(json);
|
||||
Assert.IsTrue(bytes.Any());
|
||||
File.WriteAllBytes(Path.Combine(directory, "srp.png"), bytes);
|
||||
}
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
NonThrowTryCatch();
|
||||
}
|
||||
|
||||
}
|
@ -31,6 +31,13 @@ public class UnitTestToolTypesController
|
||||
_ControllerName = nameof(Server.ApiControllers.ToolTypesController)[..^10];
|
||||
}
|
||||
|
||||
private static void NonThrowTryCatch()
|
||||
{
|
||||
try
|
||||
{ throw new Exception(); }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestControllerName()
|
||||
{
|
||||
|
Reference in New Issue
Block a user