Example #1
0
 public void MultipleItems()
 {
     double price1 = AnyInstance.AnyDouble;
     double price2 = AnyInstance.AnyDouble + 1;
     int amount1 = AnyInstance.AnyInt;
     int amount2 = AnyInstance.AnyInt + 3;
     PricingService service = new PricingService(new MockProductRepository(x => new Product { Id = x, UnitPrice = x == 1 ? price1 : price2 }));
     service.AddToCart(new OrderItem { ItemId = 1, Amount = amount1 });
     service.AddToCart(new OrderItem { ItemId = 2, Amount = amount2 });
     double expectedPrice = price1 * amount1 + price2 * amount2;
     Assert.AreEqual(expectedPrice, service.PriceOrder());
 }
Example #2
0
 public void OneItem()
 {
     double price = AnyInstance.AnyDouble;
     PricingService service = new PricingService(new MockProductRepository(x => new Product { Id = x, UnitPrice = price }));
     service.AddToCart(new OrderItem { Amount = 1, ItemId = 1 });
     Assert.AreEqual(price, service.PriceOrder());
 }
Example #3
0
        public void MultipleItems()
        {
            double         price1  = AnyInstance.AnyDouble;
            double         price2  = AnyInstance.AnyDouble + 1;
            int            amount1 = AnyInstance.AnyInt;
            int            amount2 = AnyInstance.AnyInt + 3;
            PricingService service = new PricingService(new MockProductRepository(x => new Product {
                Id = x, UnitPrice = x == 1 ? price1 : price2
            }));

            service.AddToCart(new OrderItem {
                ItemId = 1, Amount = amount1
            });
            service.AddToCart(new OrderItem {
                ItemId = 2, Amount = amount2
            });
            double expectedPrice = price1 * amount1 + price2 * amount2;

            Assert.AreEqual(expectedPrice, service.PriceOrder());
        }
Example #4
0
        public void OneItem()
        {
            double         price   = AnyInstance.AnyDouble;
            PricingService service = new PricingService(new MockProductRepository(x => new Product {
                Id = x, UnitPrice = price
            }));

            service.AddToCart(new OrderItem {
                Amount = 1, ItemId = 1
            });
            Assert.AreEqual(price, service.PriceOrder());
        }