public async Task Create_ShouldReturnsSuccessResult() { var client = factory.GetHttpClient(); var request = new CreateProduct.CreateProductCommand() { CategoryId = 1, ShopId = 1, Name = "TestProduct", Vendor = "Factory", BasePrice = new BasePriceDto { Price = 100 } }; var response = await client.PostAsJsonAsync("/api/products/", request); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <int>(responseString); result.Should().BeGreaterThan(0); response.StatusCode.Should().Be(HttpStatusCode.Created); response.Headers.Location.LocalPath.Should().Be($"/api/Products/{result}"); }
public async Task GetAllCategories_ShouldReturnsSuccessResult() { var client = factory.GetHttpClient(); var response = await client.GetAsync("/api/category/"); response.EnsureSuccessStatusCode(); var responseString = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject <IEnumerable <GetCategoriesList.CategoryDto> >(responseString); result.Should().NotBeEmpty(); result.Should().HaveCount(2); }