Ejemplo n.º 1
0
        private void Get_Tax_Rates_Test(int year, int month, int day, TaxRateDb sut)
        {
            // Assign
            DateTime date = new DateTime(year,month,day);
            TaxBracket tb = new TaxBracket
            {
                BaseRate = 0.19m,
                BaseTax = 0M,
                MinSalaryValue = 18201,
                MaxSalaryValue = 37000,
                StartDate = new DateTime(2012, 7, 1)
            };
            sut.AddTaxRate(TestStubs.TaxBrackets()[0]);
            sut.AddTaxRate(tb);

            //Assign the expected
            List<TaxBracket> expected = new List<TaxBracket>();
            expected.Add(tb);
            expected.Add(TestStubs.TaxBrackets()[0]);

            // Adding rate outside range to test for
            sut.AddTaxRate(
                   new TaxBracket
                   {
                       BaseRate = 0.37m,
                       BaseTax = 17547m,
                       MinSalaryValue = 80001,
                       MaxSalaryValue = 180000,
                       StartDate = new DateTime(2013, 7, 1)
                   });

            //Act
            List<TaxBracket> actual = sut.GetRates(date).ToList();
            CompareLogic compareLogic = new CompareLogic();
            ComparisonResult result = compareLogic.Compare(expected, actual);

            // Assert tax to verify it works
            Assert.True(result.AreEqual);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Parses the rate line from CSV to be added to TaxRateDB (in-memory)
        /// </summary>
        /// <param name="line"></param>
        public void ProcessLine(string line)
        {
            if (!string.IsNullOrEmpty(line))
            {
                string[] processLine = line.Split(',');

                if (processLine.Length > 0)
                {
                    var bracket = new TaxBracket
                    {
                        BaseTax = processLine[Convert.ToInt32(TaxRateProcessingIndex.BaseTax)].StringToDecimal(),

                        BaseRate = processLine[Convert.ToInt32(TaxRateProcessingIndex.BaseRate)].StringToDecimal(),

                        MinSalaryValue =
                            processLine[Convert.ToInt32(TaxRateProcessingIndex.MinSalaryValue)].StringToDecimal(),

                        MaxSalaryValue =
                            processLine[Convert.ToInt32(TaxRateProcessingIndex.MaxSalaryValue)].StringToDecimal(),

                        StartDate =
                            processLine[Convert.ToInt32(TaxRateProcessingIndex.StartDate)].ConvertStringtoDateTime()
                    };

                    RateValidator rateValidator = new RateValidator();

                    ValidationResult results = rateValidator.Validate(bracket);

                    if (results.IsValid)
                    {
                        _taxRates.AddTaxRate(bracket);
                    }

                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Add Rates to the collection
 /// </summary>
 /// <param name="rate"></param>
 public void AddTaxRate(TaxBracket rate)
 {
     TaxRatesCollection.Add(rate);
 }