Esempio n. 1
0
        public void throw_exception_if_income_not_larger_than_0()
        {
            //arrange
            var service = new CalculateService();

            // assert
            Assert.Catch <ArgumentException>(() => service.Calculate(_taxRate, -0.1m));
            Assert.Catch <ArgumentException>(() => service.Calculate(_taxRate, 0m));
        }
Esempio n. 2
0
            public void Shoul_Calculate_When_Pass_Null()
            {
                var instance = new CalculateService();

                int expectedResult = instance.Calculate(null);

                Assert.That(expectedResult, Is.EqualTo(0));
            }
Esempio n. 3
0
            public void Should_Calculate_More_Then_One_Digit_Format_When_Pass_String_Any_Symbol_Separated()
            {
                var instance = new CalculateService();

                int expectedResult = instance.Calculate("12,34");

                Assert.That(expectedResult, Is.EqualTo(46));
            }
Esempio n. 4
0
            public void Should_Calculate_When_Pass_String_Any_Symbol_Separated()
            {
                var instance = new CalculateService();

                int expectedResult = instance.Calculate("1;2,3+4");

                Assert.That(expectedResult, Is.EqualTo(10));
            }
Esempio n. 5
0
        public void calculate_tax_200000()
        {
            //arrange
            var service = new CalculateService();

            // act
            var result = service.Calculate(_taxRate, 200000m);

            // assert
            Assert.IsNotEmpty(result.Description);
            Assert.AreEqual(200000m, result.TaxableIncome);
            Assert.AreEqual(67426.16m, result.TotalAmount);
        }
Esempio n. 6
0
        public void calculate_tax_19404()
        {
            //arrange
            var service = new CalculateService();

            // act
            var result = service.Calculate(_taxRate, 19404.004m);

            // assert
            Assert.IsNotEmpty(result.Description);
            Assert.AreEqual(19404.004m, result.TaxableIncome);
            Assert.AreEqual(228.76076m, result.TotalAmount);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            var calculateService = new CalculateService();

            string formulaTemple = "{{arg.a}}+{{arg.b}}";

            var arg = new ParaModel()
            {
                a = 1, b = 2
            };
            var arg2 = new ParaModel()
            {
                a = 1, b = 2
            };


            var result = calculateService.Calculate(formulaTemple, () => new { arg, arg2 });

            Console.WriteLine(result);
        }
Esempio n. 8
0
 public void WhenDividByZeroGetResult()
 {
     CalculateService calcService = new CalculateService();
     string           result      = calcService.Calculate("4/2");
 }
Esempio n. 9
0
        public double Post([FromBody] CalculateViewModel calculateViewModel)
        {
            var result = _calculateService.Calculate(calculateViewModel.Formula, () => new { calculateViewModel.para });

            return(result);
        }
Esempio n. 10
0
 public CalculationsViewModel Calculate(DateTime startDate, DateTime endDate)
 {
     return(_service.Calculate(startDate, endDate));
 }