CORS, Theme, Better flow and dotnet tools - II

This commit is contained in:
2023-01-05 12:40:46 -07:00
parent 978e698da5
commit 85028743ed
21 changed files with 246 additions and 69 deletions

View File

@ -12,10 +12,10 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="3.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
<PackageReference Include="MSTest.TestAdapter" Version="3.0.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Expose-MyIT.Shared.csproj" />

View File

@ -3,7 +3,7 @@ using Expose.MyIT.Shared.ViewModels;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using System.Net;
using System.Net.Http.Json;
namespace Expose.MyIT.Tests;
@ -68,13 +68,9 @@ public class UnitTestServiceShopOrderController
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(IServiceShopOrderController<object>.Action.All);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string result = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsTrue(result != "[]");
ServiceShopOrder[]? serviceShopOrders = await httpClient.GetFromJsonAsync<ServiceShopOrder[]>($"api/{_ControllerName}/{actionName}");
Assert.IsNotNull(serviceShopOrders);
Assert.IsTrue(serviceShopOrders.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}

View File

@ -3,7 +3,7 @@ using Expose.MyIT.Shared.ViewModels;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using System.Net;
using System.Net.Http.Json;
namespace Expose.MyIT.Tests;
@ -68,13 +68,9 @@ public class UnitTestSsaOrderController
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
string actionName = nameof(ISsaOrderController<object>.Action.All);
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}/{actionName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string result = await httpResponseMessage.Content.ReadAsStringAsync();
httpClient.Dispose();
Assert.IsNotNull(result);
Assert.IsTrue(result != "[]");
SsaOrder[]? ssaOrders = await httpClient.GetFromJsonAsync<SsaOrder[]>($"api/{_ControllerName}/{actionName}");
Assert.IsNotNull(ssaOrders);
Assert.IsTrue(ssaOrders.Any());
_Logger.Information($"{_TestContext?.TestName} completed");
}

View File

@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Serilog;
using System.Net;
namespace Expose.MyIT.Tests;
@ -39,12 +38,8 @@ public class UnitTestWeatherForecastController
{
HttpClient httpClient = _WebApplicationFactory.CreateClient();
_Logger.Information("Starting Web Application");
HttpResponseMessage httpResponseMessage = await httpClient.GetAsync($"api/{_ControllerName}");
Assert.AreEqual(HttpStatusCode.OK, httpResponseMessage.StatusCode);
Assert.AreEqual("application/json; charset=utf-8", httpResponseMessage.Content.Headers.ContentType?.ToString());
string result = await httpResponseMessage.Content.ReadAsStringAsync();
string result = await httpClient.GetStringAsync($"api/{_ControllerName}");
Assert.IsNotNull(result);
httpClient.Dispose();
_Logger.Information($"{_TestContext?.TestName} completed");
}