public async Task Clear_Basket_Should_Return_Success()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            Guid      basketId = Guid.NewGuid();
            Guid      itemId   = Guid.NewGuid();
            const int quantity = 2;

            var addItemToBasketRequest = new AddItemToBasketRequest {
                Quantity = quantity, ItemId = itemId
            };

            await EnsureTokenIsCreated();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            await _client.PutAsync($"/{basketId}", addItemToBasketRequest.ToJsonStringContent());

            HttpResponseMessage response = await _client.DeleteAsync($"/{basketId}/clear");

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            response.EnsureSuccessStatusCode();
        }
示例#2
0
        public async Task Add_Item_To_Basket_With_Zero_Quantity_Should_Return_BadRequest()
        {
            var customerId = 5;
            var itemId     = 1;
            var quantity   = 0;
            var request    = new AddItemToBasketRequest {
                Quantity = quantity, ItemId = itemId
            };

            var response = await Client.PostAsync($"/api/v1/basket/{customerId}", request.ToJsonStringContent());

            response.StatusCode.Should().BeEquivalentTo(HttpStatusCode.BadRequest);
        }
示例#3
0
        public async Task Add_Item_To_Basket_Should_Return_Success()
        {
            var customerId = 5;
            var itemId     = 1;
            var quantity   = 2;
            var request    = new AddItemToBasketRequest {
                ItemId = itemId, Quantity = quantity
            };

            var response = await Client.PostAsync($"/api/v1/basket/{customerId}", request.ToJsonStringContent());

            response.EnsureSuccessStatusCode();
        }
        public async Task Add_Item_To_Basket_With_Zero_Quantity_Should_Return_BadRequest()
        {
            //-----------------------------------------------------------------------------------------------------------
            // Arrange
            //-----------------------------------------------------------------------------------------------------------
            Guid      basketId = Guid.NewGuid();
            Guid      itemId   = Guid.NewGuid();
            const int quantity = 0;
            var       request  = new AddItemToBasketRequest {
                Quantity = quantity, ItemId = itemId
            };

            await EnsureTokenIsCreated();

            //-----------------------------------------------------------------------------------------------------------
            // Act
            //-----------------------------------------------------------------------------------------------------------
            HttpResponseMessage response = await _client.PutAsync($"/{basketId}", request.ToJsonStringContent());

            //-----------------------------------------------------------------------------------------------------------
            // Assert
            //-----------------------------------------------------------------------------------------------------------
            response.StatusCode.Should().BeEquivalentTo(HttpStatusCode.BadRequest);
        }