示例#1
0
        public void Calculate_OrderContainsNoItems_ReturnsOrderWithTotalZero()
        {
            //given
            var order      = new Order(1);
            var calculator = new DefaultBarCalculator();

            //when
            var result = calculator.Calculate(order);

            //then
            Assert.That(result, Is.EqualTo(0));
        }
示例#2
0
        public void Calculate_ReturnsOrderWithTotalSet()
        {
            //given
            var order = new Order(1)
            {
                Beverages = new List <Beverage>
                {
                    new Beverage
                    {
                        Price     = 5,
                        Additives = new List <Additive>
                        {
                            new Additive {
                                Price = 2
                            },
                            new Additive {
                                Price = 2
                            },
                            new Additive {
                                Price = 1
                            },
                        }
                    },
                    new Beverage
                    {
                        Price     = 15,
                        Additives = new List <Additive>
                        {
                            new Additive {
                                Price = 1
                            },
                            new Additive {
                                Price = 1
                            },
                            new Additive {
                                Price = 1
                            },
                        }
                    }
                }
            };

            var calculator = new DefaultBarCalculator();

            //when
            var result = calculator.Calculate(order);

            //then
            Assert.That(result, Is.EqualTo(28));
        }