Files
eShopOnWeb/tests/PublicApiIntegrationTests/CatalogItemEndpoints/CatalogItemGetByIdEndpointTest.cs
Steve Smith d2412a84a9 Fix Null Warnings (#874)
* Fixing null warnings

* Fix null warnings
Fix other compiler warnings
2023-03-20 11:52:14 -04:00

32 lines
1020 B
C#

using Microsoft.eShopWeb;
using Microsoft.eShopWeb.PublicApi.CatalogItemEndpoints;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Net;
using System.Threading.Tasks;
namespace PublicApiIntegrationTests.CatalogItemEndpoints;
[TestClass]
public class CatalogItemGetByIdEndpointTest
{
[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<GetByIdCatalogItemResponse>();
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");
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
}
}