public void ConfigureTest()
        {
            // Complex model
            var customer = new Customer
            {
                Name = "George Costanza"
            };
            var order = new Order
            {
                Customer = customer,
                id = 0
            };
            var bosco = new Product
            {
                Name = "Bosco",
                Price = 4.99m
            };
            order.AddOrderLineItem(bosco, 15);

            AutoMapperConfiguration.Configure();

            // Configure AutoMapper
            OrderDetailsViewModel dto = Mapper.Map<Order, OrderDetailsViewModel>(order);

            //Assert
            Assert.AreEqual("George Costanza", dto.CustomerName, "Customer name doesn't match");
            Assert.AreEqual("£74.85", dto.Total, "Total does not match");
            Assert.AreEqual(dto.OrderLineItem[0], "Bosco: Quantity - 15", "Order Line item Does not match");
        }
        public static void SetupData()
        {
            customers.Add(new Customer
            {
                Name = "Fernando Alonso"
            });

            orders.Add(new Order
                {
                    id = 1,
                    Customer = customers[0]
                });
            orders.Add(new Order
            {
                id = 2,
                Customer = customers[0]
            });

            var widget = new Product
                {
                    Name = "Widget",
                    Price = 4.99m
                };
            var gadget = new Product
            {
                Name = "Gadget",
                Price = 6.99m
            };

            var gizmo = new Product
            {
                Name = "Gizmo",
                Price = 8.99m
            };

            products.Add(widget);
            products.Add(gadget);
            products.Add(gizmo);

            orders[0].AddOrderLineItem(widget, 15);
            orders[0].AddOrderLineItem(gizmo, 5);
        }
Esempio n. 3
0
 public void AddOrderLineItem(Product product, int quantity)
 {
     _orderLineItems.Add(new OrderLineItem(product, quantity));
 }
Esempio n. 4
0
 public void AddOrderLineItem(Product product, int quantity)
 {
     OrderLineItems.Add(new OrderLineItem { Product = product, Quantity = quantity });
 }