diff --git a/src/Web/Web.csproj b/src/Web/Web.csproj
index 35c6f0a..6ed273b 100644
--- a/src/Web/Web.csproj
+++ b/src/Web/Web.csproj
@@ -19,7 +19,6 @@
-
diff --git a/src/Web/appsettings.Docker.json b/src/Web/appsettings.Docker.json
index bac53d6..07ea75e 100644
--- a/src/Web/appsettings.Docker.json
+++ b/src/Web/appsettings.Docker.json
@@ -1,7 +1,7 @@
{
"ConnectionStrings": {
- "CatalogConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;",
- "IdentityConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;"
+ "CatalogConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.CatalogDb;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;TrustServerCertificate=true;",
+ "IdentityConnection": "Server=sqlserver,1433;Integrated Security=true;Initial Catalog=Microsoft.eShopOnWeb.Identity;User Id=sa;Password=@someThingComplicated1234;Trusted_Connection=false;TrustServerCertificate=true;"
},
"baseUrls": {
"apiBase": "http://localhost:5200/api/",
diff --git a/src/Web/appsettings.json b/src/Web/appsettings.json
index 70989a6..c2bc659 100644
--- a/src/Web/appsettings.json
+++ b/src/Web/appsettings.json
@@ -17,4 +17,4 @@
},
"AllowedHosts": "*"
}
-}
\ No newline at end of file
+}
diff --git a/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs b/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs
index 72d1f23..88b37bf 100644
--- a/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs
+++ b/tests/FunctionalTests/Web/Controllers/OrderControllerIndex.cs
@@ -23,7 +23,7 @@ public class OrderIndexOnGet : IClassFixture
public async Task ReturnsRedirectGivenAnonymousUser()
{
var response = await Client.GetAsync("/order/my-orders");
- var redirectLocation = response.Headers.Location.OriginalString;
+ var redirectLocation = response!.Headers.Location!.OriginalString;
Assert.Equal(HttpStatusCode.Redirect, response.StatusCode);
Assert.Contains("/Account/Login", redirectLocation);
diff --git a/tests/FunctionalTests/Web/Pages/Basket/BasketPageCheckout.cs b/tests/FunctionalTests/Web/Pages/Basket/BasketPageCheckout.cs
index dd19a71..be2dbb0 100644
--- a/tests/FunctionalTests/Web/Pages/Basket/BasketPageCheckout.cs
+++ b/tests/FunctionalTests/Web/Pages/Basket/BasketPageCheckout.cs
@@ -45,6 +45,6 @@ public class BasketPageCheckout : IClassFixture
formContent = new FormUrlEncodedContent(keyValues);
var postResponse2 = await Client.PostAsync("/Basket/Checkout", formContent);
- Assert.Contains("/Identity/Account/Login", postResponse2.RequestMessage.RequestUri.ToString());
+ Assert.Contains("/Identity/Account/Login", postResponse2!.RequestMessage!.RequestUri!.ToString()!);
}
}
diff --git a/tests/FunctionalTests/Web/Pages/Basket/CheckoutTest.cs b/tests/FunctionalTests/Web/Pages/Basket/CheckoutTest.cs
index 4657d77..8d6c0be 100644
--- a/tests/FunctionalTests/Web/Pages/Basket/CheckoutTest.cs
+++ b/tests/FunctionalTests/Web/Pages/Basket/CheckoutTest.cs
@@ -62,7 +62,7 @@ public class CheckoutTest : IClassFixture
var checkOutResponse = await Client.PostAsync("/basket/checkout", checkOutContent);
var stringCheckOutResponse = await checkOutResponse.Content.ReadAsStringAsync();
- Assert.Contains("/Basket/Success", checkOutResponse.RequestMessage.RequestUri.ToString());
+ Assert.Contains("/Basket/Success", checkOutResponse.RequestMessage!.RequestUri!.ToString());
Assert.Contains("Thanks for your Order!", stringCheckOutResponse);
}
}
diff --git a/tests/FunctionalTests/Web/Pages/Basket/IndexTest.cs b/tests/FunctionalTests/Web/Pages/Basket/IndexTest.cs
index cd36458..1f68da7 100644
--- a/tests/FunctionalTests/Web/Pages/Basket/IndexTest.cs
+++ b/tests/FunctionalTests/Web/Pages/Basket/IndexTest.cs
@@ -52,7 +52,7 @@ public class IndexTest : IClassFixture
var stringUpdateResponse = await updateResponse.Content.ReadAsStringAsync();
- Assert.Contains("/basket/update", updateResponse.RequestMessage.RequestUri.ToString());
+ Assert.Contains("/basket/update", updateResponse!.RequestMessage!.RequestUri!.ToString()!);
decimal expectedTotalAmount = 416.50M;
Assert.Contains(expectedTotalAmount.ToString("N2"), stringUpdateResponse);
}
@@ -92,7 +92,7 @@ public class IndexTest : IClassFixture
var stringUpdateResponse = await updateResponse.Content.ReadAsStringAsync();
- Assert.Contains("/basket/update", updateResponse.RequestMessage.RequestUri.ToString());
+ Assert.Contains("/basket/update", updateResponse!.RequestMessage!.RequestUri!.ToString()!);
Assert.Contains("Basket is empty", stringUpdateResponse);
}
}
diff --git a/tests/FunctionalTests/Web/WebPageHelpers.cs b/tests/FunctionalTests/Web/WebPageHelpers.cs
index d858bfb..1259c9e 100644
--- a/tests/FunctionalTests/Web/WebPageHelpers.cs
+++ b/tests/FunctionalTests/Web/WebPageHelpers.cs
@@ -22,6 +22,6 @@ public static class WebPageHelpers
{
var regex = new Regex(regexpression);
var match = regex.Match(input);
- return match.Groups.Values.LastOrDefault().Value;
+ return match!.Groups!.Values!.LastOrDefault()!.Value;
}
}
diff --git a/tests/FunctionalTests/Web/WebTestFixture.cs b/tests/FunctionalTests/Web/WebTestFixture.cs
index 55b2e74..d9bb491 100644
--- a/tests/FunctionalTests/Web/WebTestFixture.cs
+++ b/tests/FunctionalTests/Web/WebTestFixture.cs
@@ -23,6 +23,16 @@ public class TestApplication : WebApplicationFactory
// Add mock/test services to the builder here
builder.ConfigureServices(services =>
{
+ var descriptors = services.Where(d =>
+ d.ServiceType == typeof(DbContextOptions) ||
+ d.ServiceType == typeof(DbContextOptions))
+ .ToList();
+
+ foreach (var descriptor in descriptors)
+ {
+ services.Remove(descriptor);
+ }
+
services.AddScoped(sp =>
{
// Replace SQLite with in-memory database for tests
diff --git a/tests/PublicApiIntegrationTests/AuthEndpoints/AuthenticateEndpointTest.cs b/tests/PublicApiIntegrationTests/AuthEndpoints/AuthenticateEndpointTest.cs
index 03a969c..62550e6 100644
--- a/tests/PublicApiIntegrationTests/AuthEndpoints/AuthenticateEndpointTest.cs
+++ b/tests/PublicApiIntegrationTests/AuthEndpoints/AuthenticateEndpointTest.cs
@@ -7,29 +7,28 @@ using Microsoft.eShopWeb.ApplicationCore.Constants;
using Microsoft.eShopWeb.PublicApi.AuthEndpoints;
using Microsoft.VisualStudio.TestTools.UnitTesting;
-namespace PublicApiIntegrationTests.AuthEndpoints
-{
- [TestClass]
- public class AuthenticateEndpoint
- {
- [TestMethod]
- [DataRow("demouser@microsoft.com", AuthorizationConstants.DEFAULT_PASSWORD, true)]
- [DataRow("demouser@microsoft.com", "badpassword", false)]
- [DataRow("baduser@microsoft.com", "badpassword", false)]
- public async Task ReturnsExpectedResultGivenCredentials(string testUsername, string testPassword, bool expectedResult)
- {
- var request = new AuthenticateRequest()
- {
- Username = testUsername,
- Password = testPassword
- };
- var jsonContent = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
- var response = await ProgramTest.NewClient.PostAsync("api/authenticate", jsonContent);
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
+namespace PublicApiIntegrationTests.AuthEndpoints;
- Assert.AreEqual(expectedResult, model.Result);
- }
+[TestClass]
+public class AuthenticateEndpoint
+{
+ [TestMethod]
+ [DataRow("demouser@microsoft.com", AuthorizationConstants.DEFAULT_PASSWORD, true)]
+ [DataRow("demouser@microsoft.com", "badpassword", false)]
+ [DataRow("baduser@microsoft.com", "badpassword", false)]
+ public async Task ReturnsExpectedResultGivenCredentials(string testUsername, string testPassword, bool expectedResult)
+ {
+ var request = new AuthenticateRequest()
+ {
+ Username = testUsername,
+ Password = testPassword
+ };
+ var jsonContent = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
+ var response = await ProgramTest.NewClient.PostAsync("api/authenticate", jsonContent);
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
+
+ Assert.AreEqual(expectedResult, model!.Result);
}
}
diff --git a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemGetByIdEndpointTest.cs b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemGetByIdEndpointTest.cs
index 5882db0..9baefde 100644
--- a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemGetByIdEndpointTest.cs
+++ b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemGetByIdEndpointTest.cs
@@ -4,29 +4,28 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using System.Threading.Tasks;
-namespace PublicApiIntegrationTests.CatalogItemEndpoints
+namespace PublicApiIntegrationTests.CatalogItemEndpoints;
+
+[TestClass]
+public class CatalogItemGetByIdEndpointTest
{
- [TestClass]
- public class CatalogItemGetByIdEndpointTest
+ [TestMethod]
+ public async Task ReturnsItemGivenValidId()
{
- [TestMethod]
- public async Task ReturnsItemGivenValidId()
- {
- var response = await ProgramTest.NewClient.GetAsync("api/catalog-items/5");
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
+ var response = await ProgramTest.NewClient.GetAsync("api/catalog-items/5");
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
- Assert.AreEqual(5, model.CatalogItem.Id);
- Assert.AreEqual("Roslyn Red Sheet", model.CatalogItem.Name);
- }
+ Assert.AreEqual(5, model!.CatalogItem.Id);
+ Assert.AreEqual("Roslyn Red Sheet", model.CatalogItem.Name);
+ }
- [TestMethod]
- public async Task ReturnsNotFoundGivenInvalidId()
- {
- var response = await ProgramTest.NewClient.GetAsync("api/catalog-items/0");
+ [TestMethod]
+ public async Task ReturnsNotFoundGivenInvalidId()
+ {
+ var response = await ProgramTest.NewClient.GetAsync("api/catalog-items/0");
- Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
- }
+ Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
}
}
diff --git a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemListPagedEndpoint.cs b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemListPagedEndpoint.cs
index 5eb3036..5470111 100644
--- a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemListPagedEndpoint.cs
+++ b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemListPagedEndpoint.cs
@@ -8,66 +8,65 @@ using System.Net.Http;
using System.Net;
using System.Threading.Tasks;
-namespace PublicApiIntegrationTests.CatalogItemEndpoints
+namespace PublicApiIntegrationTests.CatalogItemEndpoints;
+
+[TestClass]
+public class CatalogItemListPagedEndpoint
{
- [TestClass]
- public class CatalogItemListPagedEndpoint
+ [TestMethod]
+ public async Task ReturnsFirst10CatalogItems()
{
- [TestMethod]
- public async Task ReturnsFirst10CatalogItems()
+ var client = ProgramTest.NewClient;
+ var response = await client.GetAsync("/api/catalog-items?pageSize=10");
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
+
+ Assert.AreEqual(10, model!.CatalogItems.Count());
+ }
+
+ [TestMethod]
+ public async Task ReturnsCorrectCatalogItemsGivenPageIndex1()
+ {
+
+ var pageSize = 10;
+ var pageIndex = 1;
+
+ var client = ProgramTest.NewClient;
+ var response = await client.GetAsync($"/api/catalog-items");
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
+ var totalItem = model!.CatalogItems.Count();
+
+ var response2 = await client.GetAsync($"/api/catalog-items?pageSize={pageSize}&pageIndex={pageIndex}");
+ response.EnsureSuccessStatusCode();
+ var stringResponse2 = await response2.Content.ReadAsStringAsync();
+ var model2 = stringResponse2.FromJson();
+
+ var totalExpected = totalItem - (pageSize * pageIndex);
+
+ Assert.AreEqual(totalExpected, model2!.CatalogItems.Count());
+ }
+
+ [DataTestMethod]
+ [DataRow("catalog-items")]
+ [DataRow("catalog-brands")]
+ [DataRow("catalog-types")]
+ [DataRow("catalog-items/1")]
+ public async Task SuccessFullMutipleParallelCall(string endpointName)
+ {
+ var client = ProgramTest.NewClient;
+ var tasks = new List>();
+
+ for (int i = 0; i < 100; i++)
{
- var client = ProgramTest.NewClient;
- var response = await client.GetAsync("/api/catalog-items?pageSize=10");
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
-
- Assert.AreEqual(10, model.CatalogItems.Count());
+ var task = client.GetAsync($"/api/{endpointName}");
+ tasks.Add(task);
}
+ await Task.WhenAll(tasks.ToList());
+ var totalKO = tasks.Count(t => t.Result.StatusCode != HttpStatusCode.OK);
- [TestMethod]
- public async Task ReturnsCorrectCatalogItemsGivenPageIndex1()
- {
-
- var pageSize = 10;
- var pageIndex = 1;
-
- var client = ProgramTest.NewClient;
- var response = await client.GetAsync($"/api/catalog-items");
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
- var totalItem = model.CatalogItems.Count();
-
- var response2 = await client.GetAsync($"/api/catalog-items?pageSize={pageSize}&pageIndex={pageIndex}");
- response.EnsureSuccessStatusCode();
- var stringResponse2 = await response2.Content.ReadAsStringAsync();
- var model2 = stringResponse2.FromJson();
-
- var totalExpected = totalItem - (pageSize * pageIndex);
-
- Assert.AreEqual(totalExpected, model2.CatalogItems.Count());
- }
-
- [DataTestMethod]
- [DataRow("catalog-items")]
- [DataRow("catalog-brands")]
- [DataRow("catalog-types")]
- [DataRow("catalog-items/1")]
- public async Task SuccessFullMutipleParallelCall(string endpointName)
- {
- var client = ProgramTest.NewClient;
- var tasks = new List>();
-
- for (int i = 0; i < 100; i++)
- {
- var task = client.GetAsync($"/api/{endpointName}");
- tasks.Add(task);
- }
- await Task.WhenAll(tasks.ToList());
- var totalKO = tasks.Count(t => t.Result.StatusCode != HttpStatusCode.OK);
-
- Assert.AreEqual(0, totalKO);
- }
+ Assert.AreEqual(0, totalKO);
}
}
diff --git a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CreateCatalogItemEndpointTest.cs b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CreateCatalogItemEndpointTest.cs
index a85923d..6c5d79e 100644
--- a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CreateCatalogItemEndpointTest.cs
+++ b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CreateCatalogItemEndpointTest.cs
@@ -8,62 +8,61 @@ using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
-namespace PublicApiIntegrationTests.AuthEndpoints
+namespace PublicApiIntegrationTests.AuthEndpoints;
+
+[TestClass]
+public class CreateCatalogItemEndpointTest
{
- [TestClass]
- public class CreateCatalogItemEndpointTest
+ private int _testBrandId = 1;
+ private int _testTypeId = 2;
+ private string _testDescription = "test description";
+ private string _testName = "test name";
+ private decimal _testPrice = 1.23m;
+
+
+ [TestMethod]
+ public async Task ReturnsNotAuthorizedGivenNormalUserToken()
{
- private int _testBrandId = 1;
- private int _testTypeId = 2;
- private string _testDescription = "test description";
- private string _testName = "test name";
- private decimal _testPrice = 1.23m;
+ var jsonContent = GetValidNewItemJson();
+ var token = ApiTokenHelper.GetNormalUserToken();
+ var client = ProgramTest.NewClient;
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
+ var response = await client.PostAsync("api/catalog-items", jsonContent);
+ Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
+ }
- [TestMethod]
- public async Task ReturnsNotAuthorizedGivenNormalUserToken()
+ [TestMethod]
+ public async Task ReturnsSuccessGivenValidNewItemAndAdminUserToken()
+ {
+ var jsonContent = GetValidNewItemJson();
+ var adminToken = ApiTokenHelper.GetAdminUserToken();
+ var client = ProgramTest.NewClient;
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
+ var response = await client.PostAsync("api/catalog-items", jsonContent);
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
+
+ Assert.AreEqual(_testBrandId, model!.CatalogItem.CatalogBrandId);
+ Assert.AreEqual(_testTypeId, model.CatalogItem.CatalogTypeId);
+ Assert.AreEqual(_testDescription, model.CatalogItem.Description);
+ Assert.AreEqual(_testName, model.CatalogItem.Name);
+ Assert.AreEqual(_testPrice, model.CatalogItem.Price);
+ }
+
+ private StringContent GetValidNewItemJson()
+ {
+ var request = new CreateCatalogItemRequest()
{
- var jsonContent = GetValidNewItemJson();
- var token = ApiTokenHelper.GetNormalUserToken();
- var client = ProgramTest.NewClient;
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
- var response = await client.PostAsync("api/catalog-items", jsonContent);
+ CatalogBrandId = _testBrandId,
+ CatalogTypeId = _testTypeId,
+ Description = _testDescription,
+ Name = _testName,
+ Price = _testPrice
+ };
+ var jsonContent = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
- Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
- }
-
- [TestMethod]
- public async Task ReturnsSuccessGivenValidNewItemAndAdminUserToken()
- {
- var jsonContent = GetValidNewItemJson();
- var adminToken = ApiTokenHelper.GetAdminUserToken();
- var client = ProgramTest.NewClient;
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
- var response = await client.PostAsync("api/catalog-items", jsonContent);
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
-
- Assert.AreEqual(_testBrandId, model.CatalogItem.CatalogBrandId);
- Assert.AreEqual(_testTypeId, model.CatalogItem.CatalogTypeId);
- Assert.AreEqual(_testDescription, model.CatalogItem.Description);
- Assert.AreEqual(_testName, model.CatalogItem.Name);
- Assert.AreEqual(_testPrice, model.CatalogItem.Price);
- }
-
- private StringContent GetValidNewItemJson()
- {
- var request = new CreateCatalogItemRequest()
- {
- CatalogBrandId = _testBrandId,
- CatalogTypeId = _testTypeId,
- Description = _testDescription,
- Name = _testName,
- Price = _testPrice
- };
- var jsonContent = new StringContent(JsonSerializer.Serialize(request), Encoding.UTF8, "application/json");
-
- return jsonContent;
- }
+ return jsonContent;
}
}
diff --git a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/DeleteCatalogItemEndpointTest.cs b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/DeleteCatalogItemEndpointTest.cs
index f41976e..98c8212 100644
--- a/tests/PublicApiIntegrationTests/CatalogItemEndpoints/DeleteCatalogItemEndpointTest.cs
+++ b/tests/PublicApiIntegrationTests/CatalogItemEndpoints/DeleteCatalogItemEndpointTest.cs
@@ -5,34 +5,33 @@ using System.Net;
using System.Net.Http.Headers;
using System.Threading.Tasks;
-namespace PublicApiIntegrationTests.CatalogItemEndpoints
+namespace PublicApiIntegrationTests.CatalogItemEndpoints;
+
+[TestClass]
+public class DeleteCatalogItemEndpointTest
{
- [TestClass]
- public class DeleteCatalogItemEndpointTest
+ [TestMethod]
+ public async Task ReturnsSuccessGivenValidIdAndAdminUserToken()
{
- [TestMethod]
- public async Task ReturnsSuccessGivenValidIdAndAdminUserToken()
- {
- var adminToken = ApiTokenHelper.GetAdminUserToken();
- var client = ProgramTest.NewClient;
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
- var response = await client.DeleteAsync("api/catalog-items/12");
- response.EnsureSuccessStatusCode();
- var stringResponse = await response.Content.ReadAsStringAsync();
- var model = stringResponse.FromJson();
+ var adminToken = ApiTokenHelper.GetAdminUserToken();
+ var client = ProgramTest.NewClient;
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
+ var response = await client.DeleteAsync("api/catalog-items/12");
+ response.EnsureSuccessStatusCode();
+ var stringResponse = await response.Content.ReadAsStringAsync();
+ var model = stringResponse.FromJson();
- Assert.AreEqual("Deleted", model.Status);
- }
+ Assert.AreEqual("Deleted", model!.Status);
+ }
- [TestMethod]
- public async Task ReturnsNotFoundGivenInvalidIdAndAdminUserToken()
- {
- var adminToken = ApiTokenHelper.GetAdminUserToken();
- var client = ProgramTest.NewClient;
- client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
- var response = await client.DeleteAsync("api/catalog-items/0");
+ [TestMethod]
+ public async Task ReturnsNotFoundGivenInvalidIdAndAdminUserToken()
+ {
+ var adminToken = ApiTokenHelper.GetAdminUserToken();
+ var client = ProgramTest.NewClient;
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", adminToken);
+ var response = await client.DeleteAsync("api/catalog-items/0");
- Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
- }
+ Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
}
}
diff --git a/tests/PublicApiIntegrationTests/ProgramTest.cs b/tests/PublicApiIntegrationTests/ProgramTest.cs
index ca92234..3f13136 100644
--- a/tests/PublicApiIntegrationTests/ProgramTest.cs
+++ b/tests/PublicApiIntegrationTests/ProgramTest.cs
@@ -2,26 +2,25 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net.Http;
-namespace PublicApiIntegrationTests
+namespace PublicApiIntegrationTests;
+
+[TestClass]
+public class ProgramTest
{
- [TestClass]
- public class ProgramTest
+ private static WebApplicationFactory _application = new();
+
+ public static HttpClient NewClient
{
- private static WebApplicationFactory _application;
-
- public static HttpClient NewClient
+ get
{
- get
- {
- return _application.CreateClient();
- }
- }
-
- [AssemblyInitialize]
- public static void AssemblyInitialize(TestContext _)
- {
- _application = new WebApplicationFactory();
-
+ return _application.CreateClient();
}
}
+
+ [AssemblyInitialize]
+ public static void AssemblyInitialize(TestContext _)
+ {
+ _application = new WebApplicationFactory();
+
+ }
}