added options factory

This commit is contained in:
StevanFreeborn
2022-07-08 16:43:32 -05:00
parent 16fe8039bb
commit bd78272a30
6 changed files with 21 additions and 15 deletions
-2
View File
@@ -4,8 +4,6 @@ namespace server.tests.Http
{ {
internal static class HttpClientFactory internal static class HttpClientFactory
{ {
public static HttpClient GetHttpClient(int version) public static HttpClient GetHttpClient(int version)
{ {
var webAppFactory = new WebApplicationFactory<Program>(); var webAppFactory = new WebApplicationFactory<Program>();
+15
View File
@@ -0,0 +1,15 @@
using System.Text.Json;
namespace server.tests.Options
{
internal static class OptionsFactory
{
public static JsonSerializerOptions GetJsonSerializerOptions()
{
return new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
};
}
}
}
@@ -7,6 +7,7 @@ using System.Net;
using System.Text.Json; using System.Text.Json;
using server.tests.Helpers; using server.tests.Helpers;
using server.tests.Http; using server.tests.Http;
using server.tests.Options;
namespace server.tests.v1.IntegrationTests namespace server.tests.v1.IntegrationTests
{ {
@@ -20,10 +21,7 @@ namespace server.tests.v1.IntegrationTests
{ {
_client = HttpClientFactory.GetHttpClient(1); _client = HttpClientFactory.GetHttpClient(1);
_serializerOptions = new JsonSerializerOptions _serializerOptions = OptionsFactory.GetJsonSerializerOptions();
{
PropertyNameCaseInsensitive = true
};
_endpoint = "/api/characters"; _endpoint = "/api/characters";
} }
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
using server.Models; using server.Models;
using server.tests.Helpers; using server.tests.Helpers;
using server.tests.Http; using server.tests.Http;
using server.tests.Options;
using System.Net; using System.Net;
using System.Text.Json; using System.Text.Json;
@@ -18,10 +19,7 @@ namespace server.tests.v1.IntegrationTests
{ {
_client = HttpClientFactory.GetHttpClient(1); _client = HttpClientFactory.GetHttpClient(1);
_serializerOptions = new JsonSerializerOptions _serializerOptions = OptionsFactory.GetJsonSerializerOptions();
{
PropertyNameCaseInsensitive = true
};
_endpoint = "/api/episodes"; _endpoint = "/api/episodes";
} }
@@ -1,4 +1,5 @@
using server.tests.Http; using server.tests.Http;
using server.tests.Options;
using System.Text.Json; using System.Text.Json;
namespace server.tests.v1.integrationTests namespace server.tests.v1.integrationTests
@@ -13,10 +14,7 @@ namespace server.tests.v1.integrationTests
{ {
_client = HttpClientFactory.GetHttpClient(1); _client = HttpClientFactory.GetHttpClient(1);
_serializerOptions = new JsonSerializerOptions _serializerOptions = OptionsFactory.GetJsonSerializerOptions();
{
PropertyNameCaseInsensitive = true
};
_endpoint = "/api/seasons"; _endpoint = "/api/seasons";
} }
@@ -1,7 +1,6 @@
using Moq; using Moq;
using server.Controllers.v1; using server.Controllers.v1;
using server.Persistence.Repositories; using server.Persistence.Repositories;
using System.Runtime.CompilerServices;
namespace server.tests.v1.unitTests namespace server.tests.v1.unitTests
{ {