Пример #1
0
        public async Task UpdateDiscount_IsSuccess()
        {
            var discount = new DiscountDTO()
            {
                ProductSKU = "TST_A01",
                Quantity   = 3,
                Price      = 2
            };

            var postResult = await controller.PostAsync(discount);

            Assert.IsInstanceOfType(postResult, typeof(CreatedNegotiatedContentResult <DiscountDTO>));

            var postResponse = postResult as CreatedNegotiatedContentResult <DiscountDTO>;

            Assert.IsNotNull(postResponse.Content);

            var createdDiscount = postResponse.Content as DiscountDTO;

            createdDiscount.Price = 1;
            var putResult = await controller.PutAsync(createdDiscount);

            var putResponse = putResult as OkNegotiatedContentResult <DiscountDTO>;

            Assert.IsNotNull(putResponse.Content);
            Assert.IsNotNull(putResponse.Content.Id);
            Assert.AreEqual(createdDiscount.ProductSKU, putResponse.Content.ProductSKU);
            Assert.AreEqual(createdDiscount.Quantity, putResponse.Content.Quantity);
            Assert.AreEqual(createdDiscount.Price, putResponse.Content.Price);
        }