public void Checkout_get_total_price_bulk_matching_offer_mixed_items_at_checkout() { // Setup ICheckout checkout = new CheckoutController(productInventory); Product inventoryProductA = productInventory.Get("A"); MultiDeal multiDealA = inventoryProductA.MultiDeal; for (int i = 0; i < multiDealA.Units; i++) { checkout.Scan(inventoryProductA); } Product inventoryProductB = productInventory.Get("B"); MultiDeal multiDealB = inventoryProductB.MultiDeal; for (int i = 0; i < multiDealB.Units; i++) { checkout.Scan(inventoryProductB); } int expectedPrice = multiDealA.MultiDealPrice + multiDealB.MultiDealPrice; // Act int actualTotalPrice = checkout.GetTotalPrice(); // Assert Assert.AreEqual(expectedPrice, actualTotalPrice); }
public virtual async Task AddressAndPayment_RedirectToCompleteWhenSuccessful() { const string cartId = "CartId_A"; var order = CreateOrder(); var formCollection = new Dictionary <string, StringValues> { { "PromoCode", new[] { "FREE" } } }; using var context = CreateContext(); await context.Database.CreateExecutionStrategy().ExecuteAsync( async() => { using (Fixture.BeginTransaction(context)) { var cartItems = CreateTestCartItems(cartId, itemPrice: 10, numberOfItems: 1); context.AddRange(cartItems.Select(n => n.Album).Distinct()); context.AddRange(cartItems); context.SaveChanges(); var controller = new CheckoutController(formCollection); var result = await controller.AddressAndPayment(context, cartId, order); Assert.Equal(order.OrderId, result); } }); }
public void Checkout_get_total_price_at_complete_checkout() { // Setup ICheckout checkout = new CheckoutController(productInventory); Product productA = productInventory.Get("A"); MultiDeal multiDealA = productA.MultiDeal; for (int i = 0; i < multiDealA.Units; i++) { checkout.Scan(productA); } checkout.Scan(productA); Product productB = productInventory.Get("B"); MultiDeal multiDealB = productB.MultiDeal; for (int i = 0; i < multiDealB.Units; i++) { checkout.Scan(productB); } checkout.Scan(productB); int expectedPrice = multiDealA.MultiDealPrice + productA.Price + multiDealB.MultiDealPrice + productB.Price; // Act int actualTotalPrice = checkout.CompleteCheckout(); // Assert Assert.AreEqual(expectedPrice, actualTotalPrice); }
public void Checkout_get_total_price_bulk_matching_offer_same_item_at_checkout_inc_offer_change() { // Setup ICheckout checkout = new CheckoutController(productInventory); string testSku = "A"; Product inventoryProductA = productInventory.Get(testSku); MultiDeal multiDealA = inventoryProductA.MultiDeal; for (int i = 0; i < multiDealA.Units; i++) { checkout.Scan(inventoryProductA); } int newDealUnits = multiDealA.Units - 1; int newDealPrice = multiDealA.MultiDealPrice * 3; int numOfMatchingDealsAfterChange = checkout.Count(testSku) / newDealUnits; int numberOfMiscProductsAfterDealChange = checkout.Count(testSku) % newDealUnits; int newExpectedPrice = (newDealPrice * numOfMatchingDealsAfterChange) + (inventoryProductA.Price * numberOfMiscProductsAfterDealChange); MultiDeal newMultiDeal = new MultiDeal(newDealUnits, newDealPrice, multiDealA.ValidFromDate, multiDealA.ValidBeforeDate); // Act int totalPriceBeforeChange = checkout.GetTotalPrice(); Assert.AreEqual(multiDealA.MultiDealPrice, totalPriceBeforeChange); // Change inventory multiDeal productInventory.Replace(new Product(testSku, inventoryProductA.Price, newMultiDeal)); int totalPriceAfterChange = checkout.GetTotalPrice(); // Assert // prove that offer change is reflected Assert.AreNotEqual(totalPriceBeforeChange, totalPriceAfterChange); Assert.AreEqual(newExpectedPrice, totalPriceAfterChange); }
public CartSteps(ScenarioContext scenarioContext) { _driver = scenarioContext["WEB_DRIVER"] as IWebDriver; products = new productsController(scenarioContext); cart = new CartController(scenarioContext); checkout = new CheckoutController(scenarioContext); }
public async Task Pay_OrderWithIdeal() { var controller = new CheckoutController(); var charge = new ChargeRequest { Amount = 70.0, Currency = "EUR", Payments = new List <PaymentRequest> { new IdealPaymentRequest { Amount = 70.0, Currency = "EUR", Details = new IdealDetailsRequest { IssuerId = "RABONL2U", SuccessUrl = "", FailedUrl = "", CancelledUrl = "", ExpiredUrl = "", PurchaseId = Guid.NewGuid().ToString("N"), Description = "Test description." } } } }; var response = await controller.ProceedPaymentAsync(charge); Assert.AreEqual(70m, response.Amount); Assert.AreEqual("Open", response.Status); }
public void WhenClearShoppingCart_ThenShoppingCartIsEmpty() { // Arrange List <Product> products = new List <Product>() { new Product() { Id = 1, Name = "A", StockQty = 2 } }; List <ShoppingCart> carts = new List <ShoppingCart>() { new ShoppingCart() { Id = 1, ProductId = 1, ProductName = "A", Quantity = 1 } }; mockCartRepo.Setup(x => x.GetAll()).Returns(carts); mockProdRepo.Setup(x => x.Get(products[0].Id)).Returns(products[0]); mockCartRepo.Setup(x => x.Clear()).Returns(true); // Act var controller = new CheckoutController(mockProdRepo.Object, mockCartRepo.Object); var result = controller.Clear() as RedirectToRouteResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); Assert.AreEqual("Home", result.RouteValues["controller"]); }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int index = Convert.ToInt32(e.CommandArgument); string id = Session["id"].ToString(); CheckoutController.DoCheckout(int.Parse(id), index, DateTime.Now); Response.Redirect("MemberHome.aspx?id=" + index); }
public void SetUp() { _gatewayAuthenticationService = new Mock <IGatewayAuthenticationService>(); _gatewayChekoutService = new Mock <IGatewayCheckoutService>(); _completeOrderService = new Mock <ICompleteOrderService>(); _completeOrderService.Setup(x => x.DelayExecution(It.IsAny <int>())); _checkoutController = new CheckoutController(_gatewayAuthenticationService.Object, _gatewayChekoutService.Object, _completeOrderService.Object); }
public void Checkout_create_checkout() { // Setup // Act ICheckout checkout = new CheckoutController(productInventory); // Assert Assert.IsNotNull(checkout); }
public MainWindow() { InitializeComponent(); this.auditor = new Auditor(); this.shipper = new Shipper(); this.checkoutController = new CheckoutController(); this.checkoutController.CheckoutProcessing += this.auditor.AuditOrder; this.checkoutController.CheckoutProcessing += this.shipper.ShipOrder; }
public void TestDeliveryDates() { var controller = new CheckoutController(); controller.Request.Cookies.Add(new System.Web.HttpCookie("meal_id", "a7d1c44f-39e2-430e-b5bd-e614be20da7f")); var result = controller.Index() as ViewResult; var deliverydates = (List <string[]>)result.ViewBag.Deliveries; Assert.IsTrue(deliverydates.Count > 0); }
public void AddressAndPayment() { // Arrange CheckoutController controller = new CheckoutController(); // Act ViewResult result = controller.AddressAndPayment() as ViewResult; // Assert Assert.IsNotNull(result); }
public CheckoutControllerTests() { this.billingService = Substitute.For <IBillingService>(); this.deliveryService = Substitute.For <IDeliveryService>(); this.orderService = Substitute.For <IOrderService>(); this.controller = Substitute.For <CheckoutController>( this.billingService, this.orderService, this.deliveryService); this.fixture = new Fixture(); }
public MainWindow() { this.InitializeComponent(); Window.Current.SizeChanged += App.WindowSizeChanged; this.auditor = new Auditor(); this.shipper = new Shipper(); this.checkoutController = new CheckoutController(); this.checkoutController.CheckoutProcessing += this.auditor.AuditOrder; this.checkoutController.CheckoutProcessing += this.shipper.ShipOrder; }
protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "SelectPaymentType") { int Row = 0; Row = Convert.ToInt16(e.CommandArgument.ToString()); String PaymentID = GridView2.Rows[Row].Cells[0].Text.ToString(); String UserID = Session["LoginSession"].ToString(); CheckoutController.DoCheckout(UserID, PaymentID); Response.Redirect("ViewCart.aspx"); } }
public void Checkout_Should_Return_Price_With_Discount() { ICheckout checkout = new CheckoutController(_mockRepository, _pricingService); checkout.Scan("A"); //50 checkout.Scan("B"); //30 checkout.Scan("A"); //50 decimal result = checkout.GetTotalPrice(); result.Should().Be(130); }
public MainPage() { this.InitializeComponent(); this.auditor = new Auditor(); this.shipper = new Shipper(); this.checkoutController = new CheckoutController(); this.checkoutController.CheckoutProcessing += this.auditor.AuditOrder; this.checkoutController.CheckoutProcessing += this.shipper.ShipOrder; this.auditor.AuditProcessingComplete += this.displayMessage; this.shipper.ShippingProcessingComplete += this.displayMessage; }
public void Checkout_scan_item_at_checkout() { // Setup ICheckout checkout = new CheckoutController(productInventory); // Act Product product = productInventory.Get("A"); checkout.Scan(product); // Assert Assert.AreEqual(1, checkout.CountAll()); }
public void CreateCheckoutController_WhenParametersAreNotNull() { // Arrange Mock <IShoppingCart> shoppingCartMock = new Mock <IShoppingCart>(); Mock <IOrderFactory> orderFactoryMock = new Mock <IOrderFactory>(); Mock <ICartIdentifier> cartIdentifierMock = new Mock <ICartIdentifier>(); //Act CheckoutController checkoutController = new CheckoutController(shoppingCartMock.Object, orderFactoryMock.Object, cartIdentifierMock.Object); // Assert Assert.That(checkoutController, Is.Not.Null); }
public MainWindow() { InitializeComponent(); _auditor = new Auditor(); _shipper = new Shipper(); _checkoutController = new CheckoutController(); _checkoutController.CheckoutProcessing += _auditor.AuditOrder; _checkoutController.CheckoutProcessing += _shipper.ShipOrder; _auditor.AuditProcessingComplete += DisplayMessage; _shipper.ShipProcessingComplete += DisplayMessage; }
public async Task Complete_ReturnsErrorIfInvalidOrder() { using (var context = CreateContext()) { using (Fixture.BeginTransaction(context)) { var controller = new CheckoutController(); var result = await controller.Complete(context, -3333); Assert.Equal("Error", result); } } }
public MainPage() { InitializeComponent(); Auditor auditor = new Auditor(); Shipper shipper = new Shipper(); _checkoutController = new CheckoutController(); _checkoutController.CheckoutProcessing += auditor.AuditOrder; _checkoutController.CheckoutProcessing += shipper.ShipOrder; auditor.AuditProcessingComplete += DisplayMessage; shipper.ShipProcessingComplete += DisplayMessage; }
public void Checkout_scan_items_in_bulk_at_checkout() { // Setup ICheckout checkout = new CheckoutController(productInventory); IList <Product> trolleyContents = shoppingTrolley.GetAll(); // Act foreach (Product product in trolleyContents) { checkout.Scan(product); } // Assert Assert.AreEqual(trolleyContents.Count, checkout.CountAll()); }
public void ShouldReturnOrder() { // Arrange var fixture = new Fixture(); var controller = new CheckoutController(); var cart = fixture.CreateMany <CartItem>(); // Act var order = controller.Checkout(cart); // Assert order.Should().NotBeNull(); order.TotalQuantity.Should().Be(cart.Count()); order.TotalPrice.Should().Be(cart.Sum(item => item.Book.Price)); }
public void Checkout_get_total_price_single_item_at_checkout() { // Setup ICheckout checkout = new CheckoutController(productInventory); Product product = productInventory.Get("A"); int price = product.Price; checkout.Scan(product); // Act int totalPrice = checkout.GetTotalPrice(); // Assert Assert.AreEqual(price, totalPrice); }
public virtual async Task Complete_ReturnsErrorIfInvalidOrder() { using var context = CreateContext(); await context.Database.CreateExecutionStrategy().ExecuteAsync( async() => { using (Fixture.BeginTransaction(context)) { var controller = new CheckoutController(); var result = await controller.Complete(context, -3333); Assert.Equal("Error", result); } }); }
public async Task CheckoutAsyncReturnsCorrectBasketTotal() { var controller = new CheckoutController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); // create basket object to pass in (value £9.29) var basketJSON = "{\"Items\":[{\"SKU\":\"T23\",\"Quantity\":1},{\"SKU\":\"A99\",\"Quantity\":7},{\"SKU\":\"C40\",\"Quantity\":2},{\"SKU\":\"B15\",\"Quantity\":5}]}"; var response = await controller.GetBasketTotal(basketJSON) as OkNegotiatedContentResult <decimal>; Assert.IsNotNull(response); Assert.IsNotNull(response.Content); Assert.AreEqual(response.Content, 9.29m); }
protected void Button1_Click(object sender, EventArgs e) { int PaymentTypeID = int.Parse(dropdownlist.SelectedValue); DateTime date = DateTime.Now; Response response = CheckoutController.doCheckout(carts, u.ID, PaymentTypeID, date); if (response.successStatus) { Response.Redirect(Request.RawUrl); } else { ErrorLabel.Visible = true; ErrorLabel.Text = response.message; } }
public void Setup() { _controllerExceptionHandler = new Mock <ControllerExceptionHandler>(); _requestContext = new Mock <RequestContext>(); _httpRequestBase = new Mock <HttpRequestBase>(); _httpContextBase = new Mock <HttpContextBase>(); _httpContextBase.Setup(x => x.Request).Returns(_httpRequestBase.Object); _exceptionContext = new ExceptionContext { HttpContext = _httpContextBase.Object, RequestContext = _requestContext.Object }; _subject = new CheckoutController(null, null, null, null, null, null, null, null, null, null, null, _controllerExceptionHandler.Object, null, null); }
public void Setup() { _controllerExceptionHandler = new Mock<ControllerExceptionHandler>(); _requestContext = new Mock<RequestContext>(); _httpRequestBase = new Mock<HttpRequestBase>(); _httpContextBase = new Mock<HttpContextBase>(); _httpContextBase.Setup(x => x.Request).Returns(_httpRequestBase.Object); _exceptionContext = new ExceptionContext { HttpContext = _httpContextBase.Object, RequestContext = _requestContext.Object }; _subject = new CheckoutController(null, null, null, null, null, null, null, null, null, null,null, _controllerExceptionHandler.Object,null); }