Exemplo n.º 1
0
        public async Task TestCrudOperationsAsync()
        {
            // Create the first price
            var price = await _controller.CreatePriceAsync(null, PRICE1);

            Assert.NotNull(price);
            Assert.True(PRICE1.Equals(price));

            // Create the second price
            price = await _controller.CreatePriceAsync(null, PRICE2);

            Assert.NotNull(price);
            Assert.True(PRICE2.Equals(price));
            // Check priority default value
            //Assert.Equal(price.Priority, PriceV1.DEFAULT_PRIORITY);

            // Get all prices
            var page = await _controller.GetPricesAsync(
                null,
                new FilterParams(),
                new PagingParams()
                );

            Assert.NotNull(page);
            Assert.Equal(2, page.Data.Count);

            var price1 = page.Data[0];

            // Update the price
            price1.Note = "ABC";

            price = await _controller.UpdatePriceAsync(null, price1);

            Assert.NotNull(price);
            Assert.Equal(price1.Id, price.Id);
            Assert.Equal("ABC", price.Note);

            // Get price by sku
            price = await _controller.GetPriceBySkuAsync(null, price1.Sku);

            Assert.NotNull(price);
            Assert.Equal(price1.Id, price.Id);

            // Delete the price
            price = await _controller.DeletePriceByIdAsync(null, price1.Id);

            Assert.NotNull(price);
            Assert.Equal(price1.Id, price.Id);

            // Try to get deleted price
            price = await _controller.GetPriceByIdAsync(null, price1.Id);

            Assert.Null(price);
        }