Fix Null Warnings (#874)

* Fixing null warnings

* Fix null warnings
Fix other compiler warnings
This commit is contained in:
Steve Smith
2023-03-20 11:52:14 -04:00
committed by GitHub
parent a2ebd3fe26
commit d2412a84a9
38 changed files with 400 additions and 285 deletions

View File

@@ -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<DeleteCatalogItemResponse>();
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<DeleteCatalogItemResponse>();
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);
}
}