Removed FromBody
This commit is contained in:
@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using OI.Metrology.Shared.DataModels;
|
||||
using OI.Metrology.Shared.Models.Stateless;
|
||||
using Serilog;
|
||||
using System.Text;
|
||||
|
||||
namespace OI.Metrology.Tests;
|
||||
|
||||
@ -39,6 +40,9 @@ public class UnitTestExportController
|
||||
private static HeaderCommon GetHeaderCommon() =>
|
||||
new() { PSN = "5008", Reactor = "61", RDS = "579487", ID = 1678209360 };
|
||||
|
||||
private static StringContent GetStringContent() =>
|
||||
new(System.Text.Json.JsonSerializer.Serialize(GetHeaderCommon()), Encoding.UTF8, "application/json");
|
||||
|
||||
[TestMethod]
|
||||
public void GetExport()
|
||||
{
|
||||
@ -55,12 +59,22 @@ public class UnitTestExportController
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers");
|
||||
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/export");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetExport)}.txt"), result);
|
||||
Assert.IsNotNull(result);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task PostExportApi()
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/export", GetStringContent());
|
||||
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetHeaders()
|
||||
{
|
||||
@ -84,6 +98,16 @@ public class UnitTestExportController
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task PostHeadersApi()
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/headers", GetStringContent());
|
||||
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetLogistics()
|
||||
{
|
||||
@ -100,13 +124,23 @@ public class UnitTestExportController
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/headers");
|
||||
string? json = await httpClient.GetStringAsync($"api/{_ControllerName}/logistics");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetLogistics)}.json"), json);
|
||||
Result<HeaderCommon[]>? result = System.Text.Json.JsonSerializer.Deserialize<Result<HeaderCommon[]>>(json);
|
||||
Assert.IsNotNull(result?.Results);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task PostLogisticsApi()
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/logistics", GetStringContent());
|
||||
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetProcessDataStandardFormat()
|
||||
{
|
||||
@ -123,10 +157,20 @@ public class UnitTestExportController
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/headers");
|
||||
string? result = await httpClient.GetStringAsync($"api/{_ControllerName}/processDataStandardFormat");
|
||||
File.WriteAllText(Path.Combine(AppContext.BaseDirectory, $"{_ControllerName}-{nameof(GetProcessDataStandardFormat)}.pdsf"), result);
|
||||
Assert.IsNotNull(result);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task PostProcessDataStandardFormatApi()
|
||||
{
|
||||
HttpClient httpClient = _WebApplicationFactory.CreateClient();
|
||||
_Logger.Information("Starting Web Application");
|
||||
HttpResponseMessage httpResponseMessage = await httpClient.PostAsync($"api/{_ControllerName}/processDataStandardFormat", GetStringContent());
|
||||
Assert.IsTrue(httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK);
|
||||
_Logger.Information($"{_TestContext?.TestName} completed");
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user