public async Task Add_Item_ToBasket_Should_Crete_Basket_And_Add() { var _basketModel = new CreateBasketModel { BuyerId = 2 }; var response = await Client.PostAsJsonAsync("/api/basket/", _basketModel); response.EnsureSuccessStatusCode(); var createdBasketResponse = await Client.GetAsync("api/basket/" + _basketModel.BuyerId); createdBasketResponse.EnsureSuccessStatusCode(); var basket = await createdBasketResponse.Content.ReadAsAsync <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(); var afterItemAddedResponse = await Client.GetAsync("api/basket/" + _basketModel.BuyerId); afterItemAddedResponse.EnsureSuccessStatusCode(); basket = await afterItemAddedResponse.Content.ReadAsAsync <Basket>(); Assert.Single(basket.BasketItems); }
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); }
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); }
public async Task Create_New_Basket_Should_Create_New_Basket_For_User() { var _basketModel = new CreateBasketModel { BuyerId = 1 }; var response = await Client.PostAsJsonAsync("/api/basket/", _basketModel); response.EnsureSuccessStatusCode(); var createdBasketResponse = await Client.GetAsync("api/basket/" + _basketModel.BuyerId); createdBasketResponse.EnsureSuccessStatusCode(); var basket = await createdBasketResponse.Content.ReadAsAsync <Basket>(); Assert.Equal(_basketModel.BuyerId, basket.BuyerId); }
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(); }