Exemplo n.º 1
0
        public static void Seed(this DataContext dataContext)
        {
            _dataContext = dataContext;

            if (!_dataContext.PostalCodeCalculationTypeMap.Any())
            {
                _dataContext.PostalCodeCalculationTypeMap.AddRange(SeedValues.GetPostalCodeCalculationTypeMap());
            }

            if (!_dataContext.FlatRate.Any())
            {
                _dataContext.FlatRate.AddRange(SeedValues.GetFlatRatesSeedValues());
            }

            if (!_dataContext.FlatValue.Any())
            {
                _dataContext.FlatValue.AddRange(SeedValues.GetFlatValueRatesSeedValues());
            }

            if (!_dataContext.ProgressiveRate.Any())
            {
                _dataContext.ProgressiveRate.AddRange(SeedValues.GetProgressiveRateSeedValues());
            }

            _dataContext.SaveChanges();
        }
        public async Task CalculateProgressiveTaxRate_WhenValidRequest_ShouldCalculateCorrectly(decimal annualIncome, decimal expectedTaxRate)
        {
            // Arrange
            var db = Db();

            db.ProgressiveRate.AddRange(SeedValues.GetProgressiveRateSeedValues());
            db.SaveChanges();
            var taxCalculator = new ProgressiveTaxCalculator(new TaxQueryService(db));

            // Act
            var taxAmount = await taxCalculator.CalculateTaxAmountAsync(annualIncome);

            // Assert
            taxAmount.ShouldBe(expectedTaxRate);
        }