Beispiel #1
0
        public async Task DeleteProduct_ReturnsAcceptedResponse_GivenValidProductId()
        {
            using (var client = new TestServerFixture().Client)
            {
                var validAddProduct = new ProductCreateRequestBuilder()
                                      .WithDefaultValues()
                                      .WithDescription("Integration testing Delete Product")
                                      .WithName("Integration Testing Delete Product")
                                      .Build();

                HttpContent addProductPayload = new StringContent(JsonConvert.SerializeObject(validAddProduct),
                                                                  Encoding.UTF8, "application/json");
                var addProductResponse = await client.PostAsync($"/v1/products", addProductPayload);

                addProductResponse.EnsureSuccessStatusCode();

                Guid.TryParse(JsonConvert.DeserializeObject(await addProductResponse.Content.ReadAsStringAsync()).ToString(),
                              out var validProductId);
                var response = await client.DeleteAsync($"/v1/products/{validProductId}");

                response.EnsureSuccessStatusCode();

                response.StatusCode.Should().Be(HttpStatusCode.Accepted);
            }
        }
Beispiel #2
0
        public async Task DeleteProductOption_ReturnsNotFound_GivenNonExistentProductId()
        {
            using (var client = new TestServerFixture().Client)
            {
                var nonExistentGuid = Guid.NewGuid();
                var response        = await client.DeleteAsync($"/v1/productoptions/{nonExistentGuid}");

                response.StatusCode.Should().Be(HttpStatusCode.NotFound);
            }
        }
Beispiel #3
0
        public async Task DeleteProductOption_ReturnsAcceptedResponse_GivenValidProductId()
        {
            using (var client = new TestServerFixture().Client)
            {
                //Arrange
                var validProductId = await GenerateValidProductId(client);

                var validProductOptionId = await GenerateValidProductOptionId(client, validProductId);

                //Act
                var response = await client.DeleteAsync($"/v1/productoptions/{validProductOptionId}");

                //Assert
                response.EnsureSuccessStatusCode();
                response.StatusCode.Should().Be(HttpStatusCode.Accepted);
            }
        }