Beispiel #1
0
        public void ShouldUpdateItemTotalAndOrderTotalOnOrderItemLineChanged()
        {
            decimal?price = 1.99m;

            productService.AddProduct(new Product(1, "1234-56789", "#2 Pencil Pack", 1.99m, null));
            productService.AddProduct(new Product(2, "9876-54321", "Stencil Pad", 0.79m, null));

            //Total set to 0, so it can be updated by the presenter.
            OrderItemLine line1 = new OrderItemLine(1, "1234-56789", "#2 Pencil Pack", price, 10, 0m, false);
            OrderItemLine line2 = new OrderItemLine(2, "9876-54321", "Stencil Pad", .79m, 10, 7.9m, false);

            view.OrderItemsLines.Add(line1);
            view.OrderItemsLines.Add(line2);

            short         newQty      = 20;
            OrderItemLine lineUpdated = new OrderItemLine(1, line1.Sku, line1.Name, line1.Price, newQty, 0, false);

            lineUpdated.Id = line1.Id;

            presenter.OnChangedOrderItemLine(lineUpdated);

            Assert.IsTrue(view.OrderItemsLinesRequested);
            Assert.IsTrue(view.OrderItemsLinesShown);
            Assert.AreEqual(newQty, view.OrderItemsLines[0].Quantity);
            Assert.AreEqual(price * newQty, view.OrderItemsLines[0].Total);
            Assert.AreEqual(line1.Total + line2.Total, view.OrderTotalPrice);
        }
 protected void OrderItemContainerDataSource_Updated(object sender, ObjectContainerDataSourceStatusEventArgs e)
 {
     _presenter.OnChangedOrderItemLine((OrderItemLine)e.Instance);
 }