Exemplo n.º 1
0
        public async Task When_A_Purchase_Order_Contains_Membership_It_Has_To_Be_Activates()
        {
            var basketModel = new CreateBasketModel {
                BuyerId = 1
            };
            //Crate Basket
            var response = await Client.PostAsJsonAsync("/api/basket/", basketModel);

            response.EnsureSuccessStatusCode();

            //Get Created Casket
            var createdBasketResponse = await Client.GetAsync("api/basket/" + basketModel.BuyerId);

            createdBasketResponse.EnsureSuccessStatusCode();
            var basket = await createdBasketResponse.Content.ReadAsAsync <Basket>();

            //Add Item To Basket
            var addBasketModel = new BasketITemPostModel
            {
                BasketId      = basket.BasketId,
                CatalogItemId = 1,
                Quantity      = 5M,
                Price         = 10.25M
            };

            var itemAddedResponse = await Client.PutAsJsonAsync("/api/basket/" + addBasketModel.BasketId, addBasketModel);

            itemAddedResponse.EnsureSuccessStatusCode();

            //Process Basket
            var purchaseOrderModel = new PurchaseOrderModel {
                BasketId = basket.BasketId.ToString()
            };
            var crateProcessOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/", purchaseOrderModel);

            crateProcessOrderResponse.EnsureSuccessStatusCode();

            //Process Purchaseorder
            var processOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/1/process", new { });

            processOrderResponse.EnsureSuccessStatusCode();

            //Verify Membership
            var buyerResponse = await Client.GetAsync("/api/buyer");

            buyerResponse.EnsureSuccessStatusCode();
            var buyer = await buyerResponse.Content.ReadAsAsync <List <Buyer> >();

            var buyerInPlan = buyer.FirstOrDefault(b => b.Id == 1).SubscriptionPlan;

            Assert.Equal(SubscriptionPlan.BookClubSubscription, buyerInPlan);
        }
Exemplo n.º 2
0
        public async Task When_A_Purchase_Order_Contains_Physical_Product_Invoice_Should_Get_Generated()
        {
            var basketModel = new CreateBasketModel {
                BuyerId = 1
            };
            //Crate Basket
            var response = await Client.PostAsJsonAsync("/api/basket/", basketModel);

            response.EnsureSuccessStatusCode();

            //Get Created Casket
            var createdBasketResponse = await Client.GetAsync("api/basket/" + basketModel.BuyerId);

            createdBasketResponse.EnsureSuccessStatusCode();
            var basket = await createdBasketResponse.Content.ReadAsAsync <Basket>();

            //Add Item To Basket
            var addBasketModel = new BasketITemPostModel
            {
                BasketId      = basket.BasketId,
                CatalogItemId = 3,
                Quantity      = 5M,
                Price         = 10.25M
            };

            var itemAddedResponse = await Client.PutAsJsonAsync("/api/basket/" + addBasketModel.BasketId, addBasketModel);

            itemAddedResponse.EnsureSuccessStatusCode();

            //Process Basket
            var purchaseOrderModel = new PurchaseOrderModel {
                BasketId = basket.BasketId.ToString()
            };
            var crateProcessOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/", purchaseOrderModel);

            crateProcessOrderResponse.EnsureSuccessStatusCode();

            //Process Purchaseorder
            var processOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/1/process", new { });

            processOrderResponse.EnsureSuccessStatusCode();

            //Verify Invoice
            var shippingInvoice = await processOrderResponse.Content.ReadAsAsync <ShippingInvoice>();


            var itemInInvoice = shippingInvoice.PurchasedItems.FirstOrDefault(o => o.ItemOrdered.CatalogItemId == 3);

            Assert.Equal(3, itemInInvoice.ItemOrdered.CatalogItemId);
        }
Exemplo n.º 3
0
        public async Task Order_Should_Process_Basket()
        {
            var basketModel = new CreateBasketModel {
                BuyerId = 1
            };
            //Crate Basket
            var response = await Client.PostAsJsonAsync("/api/basket/", basketModel);

            response.EnsureSuccessStatusCode();

            //Get Created Casket
            var createdBasketResponse = await Client.GetAsync("api/basket/" + basketModel.BuyerId);

            createdBasketResponse.EnsureSuccessStatusCode();
            var basket = await createdBasketResponse.Content.ReadAsAsync <Basket>();

            //Add Item To Basket
            var addBasketModel = new BasketITemPostModel
            {
                BasketId      = basket.BasketId,
                CatalogItemId = 1,
                Quantity      = 5M,
                Price         = 10.25M
            };

            var itemAddedResponse = await Client.PutAsJsonAsync("/api/basket/" + addBasketModel.BasketId, addBasketModel);

            itemAddedResponse.EnsureSuccessStatusCode();

            //Process Basket
            var purchaseOrderModel = new PurchaseOrderModel {
                BasketId = basket.BasketId.ToString()
            };
            var crateProcessOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/", purchaseOrderModel);

            crateProcessOrderResponse.EnsureSuccessStatusCode();

            //Process Purchaseorder

            var processOrderResponse = await Client.PostAsJsonAsync("/api/purchase-orders/1/process", new { });

            processOrderResponse.EnsureSuccessStatusCode();
        }