Example #1
0
        public Task <decimal> CalculateTaxAsync(Item item, int count)
        {
            var     subtotal = item.Price * count;
            decimal tax      = 0;

            if (!item.IsExemptFromBasicSalesTax)
            {
                tax += RoundHelper.RoundToNearest(subtotal * this.salesTax, TaxRoundsUpTo);
            }

            if (item.IsImported)
            {
                tax += RoundHelper.RoundToNearest(subtotal * this.importTax, TaxRoundsUpTo);
            }

            return(Task.FromResult(subtotal + tax));
        }
 public void Round_WhenRoundingToNegative_Throws()
 {
     Assert.Throws <InvalidOperationException>(() => RoundHelper.RoundToNearest(10, -3));
 }
        public void Round_WhenUsingIntegerRounding_RoundsUpToNearestValue(decimal value, decimal roundTo, decimal expected)
        {
            var result = RoundHelper.RoundToNearest(value, roundTo);

            Assert.Equal(expected, result);
        }