public async Task ReturnUnprocessableEntityErrorWithZeroPriceAndDelivery() { // Arrange var createProductRequest = new CreateProductRequestBuilder() .Price(0M) .DeliveryPrice(0M) .Build(); // Act var response = await TestClient.PostAsJsonAsync(ApiRoutes.Products.Create, createProductRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); }
public async Task ReturnUnprocessableEntityErrorWithLongAttributeValue() { // Arrange var createProductRequest = new CreateProductRequestBuilder() .Name(Constansts.LONG_PRODUCT_NAME) .Description(Constansts.LONG_PRODUCT_DESCRIPTION) .Build(); // Act var response = await TestClient.PostAsJsonAsync(ApiRoutes.Products.Create, createProductRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); }
public async Task ReturnUnprocessableEntityErrorForEmptyAttributes() { // Arrange var createProductRequest = new CreateProductRequestBuilder() .Name(string.Empty) .Description(string.Empty) .Price(0M) .DeliveryPrice(0M) .Build(); // Act var response = await TestClient.PostAsJsonAsync(ApiRoutes.Products.Create, createProductRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.UnprocessableEntity); }
public async Task CreateNewProduct() { // Arrange var createProductRequest = new CreateProductRequestBuilder().Build(); // Act var response = await TestClient.PostAsJsonAsync(ApiRoutes.Products.Create, createProductRequest); // Assert response.StatusCode.Should().Be(HttpStatusCode.Created); response.Headers.Location.Should().NotBeNull(); var createdProduct = (await response.Content.ReadAsAsync <ProductResponse>()); createdProduct.Should().NotBeNull(); createdProduct.Id.Should().NotBeEmpty(); createdProduct.Name.Should().Be(createProductRequest.Name); createdProduct.Description.Should().Be(createProductRequest.Description); createdProduct.Price.Should().Be(createProductRequest.Price); createdProduct.DeliveryPrice.Should().Be(createProductRequest.DeliveryPrice); }