public void Discount_BronzeLevel()
        {
            double discount = _discountService.ByCutomerForLastSales(1, 100);

            //Should be 2.5% (Bronze discount)
            Assert.AreEqual(discount, Discount.BRONZE_RATE);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <IDiscountService, DiscountService>()
                                  .AddSingleton <ISalesService, SalesService>()
                                  .AddSingleton <IDataBase, ProdDB>()
                                  .AddSingleton <IDataAccessLayer, _DAL>()
                                  .BuildServiceProvider();

            Console.WriteLine("Enter customer ID");
            var customerId = int.Parse(Console.ReadLine() ?? "");

            Console.WriteLine("Enter sale amount");
            var saleAmount = double.Parse(Console.ReadLine() ?? "");

            IDiscountService discountService = serviceProvider.GetService <IDiscountService>();

            double discount = discountService.ByCutomerForLastSales(customerId, saleAmount);

            Console.WriteLine("Discount = " + discount);
        }