public IVoucher Create(VoucherFactoryType voucherFactoryType, string voucherCode, string voucherName)
        {
            _voucherCode = voucherCode;
            _voucherName = voucherName;

            _vouchers = new Dictionary <VoucherFactoryType, IVoucher>
            {
                { VoucherFactoryType.GiftVoucher5PoundsOff, GiftVoucher5PoundsOff },
                { VoucherFactoryType.OfferVoucher5PoundsOffBasketsOver50Pounds, OfferVoucher5PoundsOffBasketsOver50Pounds },
                { VoucherFactoryType.OfferVoucher5PoundsOffBasketsOver50PoundsHeadGearOnly, OfferVoucher5PoundsOffBasketsOver50PoundsHeadGearOnly },
            };

            Guard.AgainstInValidFactoryVoucherType(_vouchers, voucherFactoryType);

            return(_vouchers[voucherFactoryType]);
        }
Exemple #2
0
        public static void AgainstInValidFactoryVoucherType(Dictionary <VoucherFactoryType, IVoucher> vouchers, VoucherFactoryType voucherFactoryType)
        {
            Guard.AgainstNull(vouchers, nameof(vouchers));

            if (!vouchers.ContainsKey(voucherFactoryType))
            {
                throw new InvalidVoucherFactoryTypeException();
            }
        }