Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                var merchantRepository = new InMemoryMerchantRepository();
                merchantRepository.Add(new Merchant(new Name("7-ELEVEN"), new Percentage(0)));
                merchantRepository.Add(new Merchant(new Name("NETTO"), new Percentage(0)));
                merchantRepository.Add(new Merchant(new Name("TELIA"), new Percentage(10)));
                merchantRepository.Add(new Merchant(new Name("CIRCLE_K"), new Percentage(20)));

                var calculateFeeHandler             = new CalculateFeeHandler(new Percentage(TransactionPercentageFee));
                var calculateFeeWithDiscountHandler = new CalculateFeeWithDiscountHandler(calculateFeeHandler,
                                                                                          merchantRepository);
                var calculateWithInvoiceFeeHandler = new CalculateFeeWithInvoiceFeeHandler(calculateFeeWithDiscountHandler,
                                                                                           new Fee(InvoiceFixedFee));

                var outputSettings = new OutputSettings();


                var transactionFeeCalculator = new FeeCalculationApp(calculateWithInvoiceFeeHandler, OutputSettings);
                transactionFeeCalculator.CalculateTransactionFees(InputFilePath);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 2
0
        public MOBILEPAY_5()
        {
            var calculateFeeHandler          = new CalculateFeeHandler(new Percentage(1));
            var calculateWithDiscountHandler = new CalculateFeeWithDiscountHandler(calculateFeeHandler, MerchantRepository);

            CommandHandler = new CalculateFeeWithInvoiceFeeHandler(calculateWithDiscountHandler, new Fee(29));
        }
        public void Handle_NullTransaction_ThrowsException()
        {
            //arrange
            var handler = new CalculateFeeHandler(new Percentage(10));

            //act & assert
            Assert.Throws <DomainException>(() => handler.Handle(null));
        }
        public void Handle_CalculatesFeeCorrectly(double amount, double percentage, double expectedFee)
        {
            //arrange
            var handler     = new CalculateFeeHandler(new Percentage(percentage));
            var transaction = new Transaction(new Date(DateTime.Now), new Name("STEAM"), new Amount(amount));

            //act
            var fee = handler.Handle(new CalculateFee(Guid.NewGuid(), transaction));

            //assert
            Assert.Equal(expectedFee, fee.Value);
        }