public void TaxFactoryProductionInvalidTest(TaxProcessorType taxType, object expectedFactory)
        {
            var taxProcessorFactory = new TaxProcessorFactory(_serviceProvider);
            var taxProcessor        = taxProcessorFactory.CreateTaxProcessor(taxType).GetType();

            Assert.False(expectedFactory.Equals(taxProcessor));
        }
        private IMonthlyTaxProcessor GetTaxAlgorithm(TaxProcessorType taxProcessorType)
        {
            switch (taxProcessorType)
            {
            case TaxProcessorType.Australian:
                _logger.Log(LogType.Trace, "Factory returning MonthlyAustralianTaxProcessor tax processor.");
                return(new MonthlyTaxProcessor(_serviceProvider));

            case TaxProcessorType.TaxFree:
                _logger.Log(LogType.Trace, "Factory returning MonthlyMockTaxFreeProcessor tax processor.");
                return(new MonthlyMockTaxFreeProcessor(_serviceProvider));

            case TaxProcessorType.AllTax:
                _logger.Log(LogType.Trace, "Factory returning MonthlyMockAllTaxProcessor tax processor.");
                return(new MonthlyMockAllTaxProcessor(_serviceProvider));

            default:
                _logger.Log(LogType.Trace, "Factory returning MonthlyAustralianTaxProcessor tax processor.");
                return(new MonthlyTaxProcessor(_serviceProvider));
            }
        }
Esempio n. 3
0
        public ITaxProcessor Create(TaxProcessorType type, IConfigurationSection options = default)
        {
            switch (type)
            {
            case TaxProcessorType.NoTax:
                return(NoTaxProcessor.Default);

            case TaxProcessorType.SimplePercent:
                if (options == default)
                {
                    throw new ArgumentException(
                              $"Options for {nameof(SimplePercentTaxProcessor)} are required. Make sure key '{nameof(TaxConfig.ProcessorOptions)}' is defined in appSettings.json.");
                }

                var opts = new SimplePercentTaxProcessorOptions();
                options.Bind(opts);

                return(new SimplePercentTaxProcessor(opts));

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }
 /// <summary>
 /// Function that returns a class that implements the IMonthlyTaxProcessor, which will be used to calculate the payslip.
 /// Used in unit tests.
 /// </summary>
 /// <param name="taxProcessorType"></param>
 /// <returns></returns>
 public IMonthlyTaxProcessor CreateTaxProcessor(TaxProcessorType taxProcessorType)
 {
     return(GetTaxAlgorithm(taxProcessorType));
 }