Ejemplo n.º 1
0
        public void Verify_Price_Before_Tax()
        {
            var calc = new RecipeCalculator();
            var quantity = 2;
            var chicken = new IngredientBO()
            {
                Id = 1,
                ProductId = 4,
                Quantity = quantity,
                RecipeId = 1,
                UnitType = Enums.UnitTypes.None
            };
            var expected = (quantity * 2.19m);

            decimal beforeTax = calc.BeforeTaxPrice(chicken);

            Assert.IsNotNull(beforeTax);
            Assert.AreEqual(expected, beforeTax);
        }
Ejemplo n.º 2
0
        public void Verify_Tax_Rate_Is_Correct()
        {
            var calc = new RecipeCalculator();
            var chicken = new IngredientBO()
            {
                Id = 1,
                ProductId = 4,
                Quantity = 17,
                RecipeId = 1,
                UnitType = Enums.UnitTypes.None
            };

            decimal beforeTax = calc.BeforeTaxPrice(chicken);
            decimal afterTax = calc.ApplySalesTax(beforeTax);
            var percentageDifference = Math.Round((Math.Round((afterTax - beforeTax), 2) / beforeTax), 3) * 100;

            Assert.IsNotNull(beforeTax);
            Assert.IsNotNull(afterTax);
            Assert.IsNotNull(percentageDifference);
            Assert.AreEqual(TaxRate, percentageDifference);
        }
Ejemplo n.º 3
0
        public decimal BeforeTaxPrice(IngredientBO ingredient)
        {
            var product = new Repository<Product, long>().GetById(ingredient.ProductId);

            return Math.Round((ingredient.Quantity * product.Price), 2);
        }