Exemplo n.º 1
0
        //This would be some ORM (likely dapper) to access gift vouchers stored in a DB
        //For the purposes of this task, I have just stubbed what I would expect
        public List <OfferVoucher> GetAllAvailableOfferVouchers()
        {
            VoucherFactory voucherFactory = new VoucherFactory();

            return(new List <OfferVoucher>()
            {
                (OfferVoucher)voucherFactory.GenerateVoucher(VouchersEnum.Offer_5PoundOffHeadgear_Threshold50),
                (OfferVoucher)voucherFactory.GenerateVoucher(VouchersEnum.Offer_5PoundOff_Threshold50)
            });
        }
Exemplo n.º 2
0
        //This would be some ORM (likely dapper) to access gift vouchers stored in a DB
        //For the purposes of this task, I have just stubbed what I would expect
        public List <GiftVoucher> GetAllAvailableGiftVouchers()
        {
            VoucherFactory voucherFactory = new VoucherFactory();

            return(new List <GiftVoucher>()
            {
                (GiftVoucher)voucherFactory.GenerateVoucher(VouchersEnum.Gift_5PoundOff)
            });
        }
Exemplo n.º 3
0
        public void CheapHat_ExpensiveJumper_5PoundGiftVoucher()
        {
            //Given a basket with a cheap hat, an expensive jumper, and �off gift voucher
            Basket basket = new Basket()
            {
                Products = new List <Product>()
                {
                    _prodFactory.GenerateProduct(ProductEnum.CheapHat),
                    _prodFactory.GenerateProduct(ProductEnum.ExpensiveJumper)
                },
                GiftVouchers = new List <GiftVoucher>()
                {
                    (GiftVoucher)_vouchFactory.GenerateVoucher(VouchersEnum.Gift_5PoundOff)
                }
            };

            //When the total is calculated
            var actual = _basketCalculator.CalculateTotal(basket);

            //Then the total should be �.15, and no error message displayed
            Assert.AreEqual(60.15m, actual.FinalTotal);
            Assert.AreEqual(null, actual.ErrorMessage);
        }