Example #1
0
        static void Main(string[] args)
        {
            var order = new Order
            {
                Items = new List <LineItem> {
                    new LineItem {
                        Price  = 2.44m,
                        Amount = 11
                    },
                    new LineItem {
                        Price  = 444m,
                        Amount = 11
                    },
                    new LineItem {
                        Price  = 0.99m,
                        Amount = 4
                    }
                }
            };

            var     calculator = new OrderTotalCalculator();
            decimal total      = calculator.Calculate(order);

            Console.WriteLine(total);
            Console.ReadKey();
        }
Example #2
0
        public void Test_CalculateTotal_WHEN_NoOrderItems_THEN_ItIs0()
        {
            var target = new OrderTotalCalculator();
            var items  = Enumerable.Empty <IOrderItem>();
            var total  = target.CalculateTotal(items, PromotionEngineTestContext.ActivePromotions);

            Assert.AreEqual(0, total);
        }
        public OrderTotalCalculatorTests()
        {
            var currencyService = Substitute.For <CurrencyService>();

            currencyService.Get(Arg.Any <Guid>()).Returns(new Currency("IQD"));

            sut = new OrderTotalCalculator(currencyService);
        }