Esempio n. 1
0
        public void should_group_amounts_by_tax_in_the_bill()
        {
            var beer    = "Beer";
            var wine    = "Wine";
            var starter = "Starter";
            var dessert = "Dessert";

            var order = new AnOrder()
                        .With(1, new ADish(beer).Build())
                        .With(1, new ADish(wine).Build())
                        .With(1, new ADish(starter).Build())
                        .With(1, new ADish(dessert).Build())
                        .Build();

            var menu = new Mock <IRepository <Dish> >();

            menu.Setup(m => m.Get(beer)).Returns(new Billing.ADish(beer).Priced(6m).OfType("Alcool").Build());         // Tax (20%) of 1 €
            menu.Setup(m => m.Get(wine)).Returns(new Billing.ADish(wine).Priced(12m).OfType("Alcool").Build());        // Tax (20%) of 2 €
            menu.Setup(m => m.Get(starter)).Returns(new Billing.ADish(starter).Priced(11m).OfType("Starter").Build()); // Tax (10%) of 1 €
            menu.Setup(m => m.Get(dessert)).Returns(new Billing.ADish(dessert).Priced(11m).OfType("Dessert").Build()); // Tax (10%) of 1 €

            var taxConfiguration = new ATaxConfiguration().Build();
            var cashRegister     = new ACashRegister(menu.Object, taxConfiguration).Build();

            var bill = cashRegister.Calculate(order);

            var tenPercentTaxAmount = bill.Taxes[taxConfiguration.Get("RED").TaxConfiguration[0]];

            Check.That(tenPercentTaxAmount).Equals(2m);
            var twentyPercentTaxAmount = bill.Taxes[taxConfiguration.Get("REG").TaxConfiguration[0]];

            Check.That(twentyPercentTaxAmount).Equals(3m);
        }
Esempio n. 2
0
        public void should_apply_a_ten_percent_discount_on_the_reduced_tax_items_of_a_take_away_bill()
        {
            var dish  = new ADish().Build();
            var order = new AnOrder()
                        .TakeAway()
                        .With(1, dish)
                        .Build();

            var menu = new Mock <IRepository <Dish> >();

            menu.Setup(m => m.Get(dish.Id)).Returns(new Billing.ADish(dish.Id).Priced(10m).WithReducedTax().Build());

            var taxConfiguration = new ATaxConfiguration().Build();
            var cashRegister     = new ACashRegister(menu.Object, taxConfiguration).Build();

            var bill = cashRegister.Calculate(order);

            var discount = bill.Discounts.First();

            Check.That(discount.Key.Rate).Equals(0.10m);
            Check.That(discount.Value).Equals(1m);
            Check.That(bill.Total).Equals(9m);
            var tenPercentTaxAmount = bill.Taxes[taxConfiguration.Get("RED").TaxConfiguration[0]];

            Check.That(tenPercentTaxAmount).Equals(0.82m);
        }
Esempio n. 3
0
        public void should_not_apply_discount_for_on_site_bills()
        {
            var dish  = new ADish().Build();
            var order = new AnOrder()
                        .OnSite("1", 2)
                        .With(1, dish)
                        .Build();

            var menu = new Mock <IRepository <Dish> >();

            menu.Setup(m => m.Get(dish.Id)).Returns(new Billing.ADish(dish.Id).Priced(10m).Build());

            var taxConfiguration = new ATaxConfiguration().Build();
            var cashRegister     = new ACashRegister(menu.Object, taxConfiguration).Build();

            var bill = cashRegister.Calculate(order);

            Check.That(bill.Total).Equals(10m);
            var tenPercentTaxAmount = bill.Taxes[taxConfiguration.Get("RED").TaxConfiguration[0]];

            Check.That(tenPercentTaxAmount).Equals(0.91m);
        }
Esempio n. 4
0
        public void should_calculate_bill_tax_from_the_sum_of_lines_amount()
        {
            var cocktail = new ADish("Cocktail").Build();

            var order = new AnOrder()
                        .With(1, cocktail)
                        .With(1, cocktail)
                        .With(1, cocktail)
                        .Build();

            var menu = new Mock <IRepository <Dish> >();

            menu.Setup(m => m.Get(cocktail.Id)).Returns(new Billing.ADish(cocktail.Id).Priced(5m).OfType("Alcool").Build()); // Tax (20%) of 0,83 €

            var taxConfiguration = new ATaxConfiguration().Build();
            var cashRegister     = new ACashRegister(menu.Object, taxConfiguration).Build();

            var bill = cashRegister.Calculate(order);

            var tax_amount = bill.Taxes[taxConfiguration.Get("REG").TaxConfiguration[0]];

            Check.That(tax_amount).Equals(2.5m); // instead of 2,49 €
        }