public void Test_containsFood_WithoutFood()
        {
            string[] testBill = new string[] { "Cola", "Coffee" };
            bool     result   = BillCalculator.containsFood(testBill);

            Assert.IsFalse(result);
        }
        public void Test_containsHot_WithoutHot()
        {
            string[] testBill = new string[] { "Cola", "Cheese Sandwich" };
            bool     result   = BillCalculator.containsHotFood(testBill);

            Assert.IsFalse(result);
        }
        public void Test_containsFood_WithFood()
        {
            string[] testBill = new string[] { "Cola", "Cheese Sandwich" };
            bool     result   = BillCalculator.containsFood(testBill);

            Assert.IsTrue(result);
        }
        public void Test_containsHot_WithHotFood()
        {
            string[] testBill = new string[] { "Cola", "Coffee", "Steak Sandwich" };
            bool     result   = BillCalculator.containsHotFood(testBill);

            Assert.IsTrue(result);
        }
Пример #5
0
        public void BillCalculator_CalculateServiceCharge_Ok()
        {
            var billCalculator = new BillCalculator();

            // All Drinks, no service charge
            var menuItems1 = new string[] { "Cola", "Coffee", "Cola", "Coffee", "Cola" };
            var charge1    = billCalculator.CalculateServiceCharge(menuItems1, 3.5D);

            Assert.AreEqual(0.0D, charge1);

            // Drinks plus cheese sandwich, 10% service charge
            var menuItems2 = new string[] { "Cola", "Coffee", "Cola", "Coffee", "Cola", "Cheese Sandwich" };
            var charge2    = billCalculator.CalculateServiceCharge(menuItems2, 5.5D);

            Assert.AreEqual(0.55D, charge2);

            // Any steak sandwich, 20% service charge
            var menuItems3 = new string[] { "Cola", "Coffee", "Cola", "Coffee", "Cola", "Steak Sandwich" };
            var charge3    = billCalculator.CalculateServiceCharge(menuItems3, 8.0D);

            Assert.AreEqual(1.6D, charge3);

            // Service charge capped at £20
            var menuItems4 = (new string[] { "Cola", "Coffee", "Cola", "Coffee", "Cola", "Cheese Sandwich" })
                             .Union(Enumerable.Repeat("Steak Sandwich", 40))
                             .ToArray();
            var charge4 = billCalculator.CalculateServiceCharge(menuItems4, 185.5D);

            Assert.AreEqual(20.0D, charge4);
        }
        public void Test_calculateBill_Basic()
        {
            string[] testBill = new string[] { "Cola", "Coffee", "Cheese Sandwich" };
            double   expected = 3.5;
            double   actual   = BillCalculator.calculateBill(testBill);

            Assert.AreEqual(expected, actual);
        }
        public void Test_calculateBill_WithEmpty()
        {
            string[] testBill = new string[] {};
            double   expected = 0;
            double   actual   = BillCalculator.calculateBill(testBill);

            Assert.AreEqual(expected, actual);
        }
        public void Test_calculateBill_WithDuplicates()
        {
            string[] testBill = new string[] { "Cola", "Coffee", "Cola" };
            double   expected = 2;
            double   actual   = BillCalculator.calculateBill(testBill);

            Assert.AreEqual(expected, actual);
        }
        public void Test_calculateServiceCharge_ColdFood()
        {
            string[] testBill = new string[] { "Cola", "Coffee", "Cheese Sandwich" };
            double   expected = 0.35;
            double   actual   = BillCalculator.calculateServiceCharge(testBill);

            Assert.AreEqual(expected, actual);
        }
 public BillGenerator(int month, int year)
 {
     BillingMonth       = month;
     BillingYear        = year;
     ConvertDbToProgram = new ConvertFromDbToProgramModel();
     ConvertProgramToDb = new ConvertFromProgramToDb();
     URepo      = new UserRepository();
     ARepo      = new ActivitiesRepository();
     Calculator = new BillCalculator();
     NewBills   = new List <BillModel>();
 }
 public BillGenerator()
 {
     BillingMonth       = (DateTime.Now.Month - 1);
     BillingYear        = (DateTime.Now.Year - 1);
     ConvertDbToProgram = new ConvertFromDbToProgramModel();
     ConvertProgramToDb = new ConvertFromProgramToDb();
     URepo      = new UserRepository();
     ARepo      = new ActivitiesRepository();
     Calculator = new BillCalculator();
     NewBills   = new List <BillModel>();
 }
Пример #12
0
        public void TestToCheckWhetherApplicationProvidesValidOutputForAGivenValidInput()
        {
            var inputProducts = new List <string>()
            {
                "1", "4", "7"
            };

            var categoryToProductsMapping = productsProvider.GetCategoryAndProductsMapping();

            var grandTotal = BillCalculator.CalculateBill(inputProducts, categoryToProductsMapping);

            Assert.AreEqual(grandTotal, 116.7);
        }
Пример #13
0
        public void BillCalculator_CalculateBill_Ok()
        {
            var billCalculator = new BillCalculator();
            var menuItems      = new string[] { "Cola", "Coffee", "Cheese Sandwich" };

            var billAmount = billCalculator.CalculateBill(menuItems);

            Assert.AreEqual(3.85D, billAmount);

            menuItems  = new string[] { "Cola", "Steak Sandwich" };
            billAmount = billCalculator.CalculateBill(menuItems);

            Assert.AreEqual(6.0D, billAmount);
        }
        public void Test_calculateServiceCharge_Maximum()
        {
            List <string> testBill = new List <string>();

            //Create very large bill
            for (int a = 0; a < 40; a = a + 1)
            {
                testBill.Add("Steak Sandwich");
            }

            double expected = 20;
            double actual   = BillCalculator.calculateServiceCharge(testBill);

            Assert.AreEqual(expected, actual);
        }
Пример #15
0
 public RetailStoreTest()
 {
     billCalculator = new BillCalculator(new PercentageDiscount(), new FixedDiscount());
 }
Пример #16
0
 public void Setup()
 {
     _service    = new RuleService();
     _calculator = new BillCalculator();
 }
Пример #17
0
        public void BillCalculator_ctor_Ok()
        {
            var billCalculator = new BillCalculator();

            Assert.IsNotNull(billCalculator);
        }