public void Calculate_WithTaxTypeNormal_ReturnsCorrectResult()
        {
            // Assign
            double  value   = 10;
            TaxType taxType = TaxType.Normal;

            // Act
            double result = _sut.Calculate(value, taxType);

            // Assert
            Check.That(result).IsEqualTo(12.1);
        }
Exemplo n.º 2
0
        public void TestSpaceshipTaxCalculatorCalculateMethodForCargoShip()
        {
            Spaceship cargoShip = new CargoShip(yearOfPurchase: 2332, milesTraveled: 344789);

            taxCalculator = new SpaceshipTax(cargoShip);
            Assert.AreEqual(expected: 326768.00, taxCalculator.Calculate(yearOfCalculation: 2369));
        }
Exemplo n.º 3
0
        public void TestSpaceshipTaxCalculatorCalculateMethodForFamilyShip()
        {
            Spaceship familyShip = new FamilyShip(yearOfPurchase: 2300, milesTraveled: 2344);

            taxCalculator = new SpaceshipTax(familyShip);

            Assert.AreEqual(expected: 2715.00, actual: taxCalculator.Calculate(yearOfCalculation: 2307));
        }
Exemplo n.º 4
0
        private double Test(DateTime date)
        {
            var r = new TaxRequest()
            {
                Municipality = "Vilnius", Date = date
            };

            return(calc.Calculate(taxRecords, r));
        }
Exemplo n.º 5
0
 public Order(ITaxCalculator taxCalculator)
 {
     CalculateTax = new Func <Func <decimal> >(() =>
     {
         decimal?tax = null;
         return(() =>
         {
             if (!tax.HasValue)
             {
                 tax = taxCalculator.Calculate(this);
             }
             return tax.Value;
         });
     })();
 }
 public ActionResult <CalculatedTaxes> Calculate(decimal grossSalary)
 {
     try
     {
         return(_polishTaxCalculator.Calculate(grossSalary));
     }
     catch (ArgumentException)
     {
         return(BadRequest());
     }
     catch (InvalidOperationException)
     {
         return(new StatusCodeResult(500));   //internal server error
     }
 }
 public TaxResponse Post(TaxRequest request)
 {
     try
     {
         var taxRate = _calc.Calculate(_data.GetMunicipalityTaxRecords(request.Municipality), request);
         var resp    = new TaxResponse()
         {
             Request = request, TaxRate = taxRate
         };
         return(resp);
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error Calculating tax rate", new { request = request });
         throw ex;
     }
 }
Exemplo n.º 8
0
        public IActionResult CalculationResult(TaxCalculatorViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Error", new ErrorViewModel()
                {
                    Message = "Please pass in a number range between 1,000 and 2,000... ya dingus!"
                }));
            }

            // DO THIS IN A SEPARATE SERVICE
            var newModel = new TaxCalculatorResultViewModel();

            newModel.Total = _taxCalculator.Calculate(model.SubTotal);

            return(View(newModel));
        }
        public TaxResponse Post(TaxRequest request)
        { 
           try {

            
           //var request = new TaxRequest(){Municipality="Vilnius", Date= new DateTime(2016,5,2) };            
           var taxRate = _calc.Calculate(_data.GetMunicipalityTaxRecords(request.Municipality),request );           
           var resp = new TaxResponse(){Request = request, TaxRate = taxRate };
           return resp;

           }catch(Exception ex)
           {
               _logger.LogError(ex,"Error Calculating tax rate", new {request= request});
               throw new Exception("Error Calculating tax rate");
           }

           
        }
Exemplo n.º 10
0
        public void TestWithTaxRatesNotSet()
        {
            var ex = Assert.Throws <InvalidOperationException>(() => taxCalculator.Calculate(1000));

            Assert.AreEqual(ErrorMessages.taxRatesNotSetErrorMessage, ex.Message);
        }
      public void TestWithNegativeSalary()
      {
          var ex = Assert.Throws <ArgumentException>(() => polishTaxCalculator.Calculate(-1500));

          Assert.AreEqual(ErrorMessages.salaryLessThanZeroErrorMessage, ex.Message);
      }
Exemplo n.º 12
0
 public decimal CalculateTax(decimal income)
 {
     return(_taxCalculator.Calculate(income));
 }
Exemplo n.º 13
0
        public IActionResult Index()
        {
            var result = _taxCalculator.Calculate(100);

            return(View());
        }
Exemplo n.º 14
0
 public decimal Calculate(ITaxCalculator cal)
 {
     return(cal.Calculate());
 }
Exemplo n.º 15
0
        public double GetTotalValue(int numProducts, double price, TaxType taxType)
        {
            double value = numProducts * price;

            return(value * _taxCalculator.Calculate(value, taxType));
        }
Exemplo n.º 16
0
        public async Task <HttpResponseMessage> Calculate(Address customer, Address supplier, OrderDetail order)
        {
            var result = await _calculator.Calculate(customer, supplier, order);

            return(result);
        }
Exemplo n.º 17
0
 private void UpdateTotals(ITaxCalculator taxCalculator)
 {
     TotalTax   = Items.Sum(x => taxCalculator.Calculate(this, x));
     TotalValue = Items.Sum(x => x.Value);
 }