public void NotApplyBulkDiscountWhenItWasAlreadyApplied()
        {
            var fakeOrder = getOneOrderForTest();

            fakeOrder.Discount = 10;
            //Expecting return Null when discount is already applied
            Assert.IsNull(ServiceDiscount.ApplyBulkDiscount(fakeOrder));
        }
Пример #2
0
        public ServiceDiscount ConvertToServiceDiscount(Discount webshopDiscount)
        {
            ServiceDiscount serviceDiscountToReturn = new ServiceDiscount();

            serviceDiscountToReturn.DiscountCode   = webshopDiscount.DiscountCode;
            serviceDiscountToReturn.DiscountAmount = webshopDiscount.DiscountAmount;

            return(serviceDiscountToReturn);
        }
Пример #3
0
        public Discount ConvertFromServiceDiscount(ServiceDiscount serviceDiscount)
        {
            Discount discountToReturn = new Discount();

            discountToReturn.DiscountCode   = serviceDiscount.DiscountCode;
            discountToReturn.DiscountAmount = serviceDiscount.DiscountAmount;

            return(discountToReturn);
        }
        public void NotApplyBulkDiscountWhenOrderNotExist()
        {
            var fakeOrder = new Order()
            {
                Key = "NotExist"
            };

            //Expecting Exception once this Key does not exist on Redis
            ServiceDiscount.ApplyBulkDiscount(fakeOrder);
        }
Пример #5
0
        public void InsertDiscount(ServiceDiscount discount)
        {
            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdInsertDiscount = connection.CreateCommand())
                {
                    cmdInsertDiscount.CommandText = "INSERT INTO Discount (discountCode, discountAmount) VALUES (@discountCode, @discountAmount)";
                    cmdInsertDiscount.Parameters.AddWithValue("name", discount.DiscountCode);
                    cmdInsertDiscount.Parameters.AddWithValue("price", discount.DiscountAmount);

                    cmdInsertDiscount.ExecuteNonQuery();
                }
            }
        }
        public void NotApplyCouponDiscountWhenItWasAlreadyApplied()
        {
            var order = getOneOrderForTest();

            //Getting created order from Redis
            order = ServiceOrder.getOrder(order.Key);

            //Applying Discount and verifying if return is not null
            Assert.IsNull(ServiceDiscount.ApplyCouponDiscount(order.Key, 100, 20));

            //Getting order from Redis after try apply discount
            order = ServiceOrder.getOrder(order.Key);

            //Verifing new Total with Discount
            Assert.AreEqual(194.15, order.Total);
        }
        public void ApplyBulkDiscount()
        {
            var order = getOneOrderForTest();

            //Creating new order on Redis
            ServiceOrder.createOrder(order.Key, order);

            //Getting created order from Redis
            order = ServiceOrder.getOrder(order.Key);

            //Verifying Total Before Apply discount
            Assert.AreEqual(205.65, order.Total);

            //Applying Discount
            ServiceDiscount.ApplyBulkDiscount(order);

            //Getting order from Redis after apply discount
            order = ServiceOrder.getOrder(order.Key);

            //Verifing new Total with Discount
            Assert.AreEqual(199.15, order.Total);
        }
        public void ApplyCouponDiscount()
        {
            var order = getOneOrderForTest();

            //Creating new order on Redis
            ServiceOrder.createOrder(order.Key, order);

            //Getting created order from Redis
            order = ServiceOrder.getOrder(order.Key);

            //Verifying Total without discount
            Assert.AreEqual(199.15, order.Total);

            //Applying Discount and Checking if the return is not null
            Assert.IsNotNull(ServiceDiscount.ApplyCouponDiscount(order.Key, 100, 5));

            //Getting order with discount applied from Redis
            order = ServiceOrder.getOrder(order.Key);

            //Verifing new Total with Discount
            Assert.AreEqual(194.15, order.Total);
        }
Пример #9
0
 public void InsertDiscount(ServiceDiscount discount)
 {
     discountControl.InsertDiscount(discount);
 }
 public void NotApplyCouponDiscountWhenOrderNotExist()
 {
     //Expecting Exception once this Key does not exist on Redis
     ServiceDiscount.ApplyCouponDiscount("NotExist", 100, 20);
 }
Пример #11
0
 public void InsertDiscount(ServiceDiscount discount)
 {
     dataDiscount.InsertDiscount(discount);
 }