コード例 #1
0
        public void TestDivison()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();
            Assert.AreEqual(calc.Calculate(4.4m, 2.2m, Calculator.models.CalculationType.DIVISTION), 2.0m);

            try
            {
                Assert.AreEqual(calc.Calculate(4.4m, 0.0m, Calculator.models.CalculationType.DIVISTION), 2.0m);
                Assert.Fail();
            }
            catch (DivideByZeroException ex)
            {
                Assert.IsTrue(true);
            }
        }
コード例 #2
0
        public void TestAddition()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();
            decimal result = calc.Calculate(2.5m, 4m, Calculator.models.CalculationType.ADDITION);

            Assert.Equal(6.5m, result);
        }
コード例 #3
0
        public void TestDivision()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();
            decimal result = calc.Calculate(2.5m, 4m, Calculator.models.CalculationType.DIVISTION);

            Assert.Equal(0.625m, result);
        }
コード例 #4
0
        public void TestMultiplication()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();
            decimal result = calc.Calculate(2.5m, 4m, Calculator.models.CalculationType.MULTIPLICATION);

            Assert.Equal(10.0m, result);
        }
コード例 #5
0
        public void TestSubtraction()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();
            decimal result = calc.Calculate(2.5m, 4m, Calculator.models.CalculationType.SUBTRACTION);

            Assert.Equal(-1.5m, result);
        }
コード例 #6
0
        public void TestDivision()
        {
            Calculator.models.Calculator calc = new Calculator.models.Calculator();

            Assert.Throws <DivideByZeroException>(() =>
            {
                decimal result = calc.Calculate(6.0m, 0.0m, Calculator.models.CalculationType.DIVISTION);
                Assert.IsType <decimal>(result);
            });
        }
コード例 #7
0
 public void TestDivisionZero()
 {
     Calculator.models.Calculator calc = new Calculator.models.Calculator();
     decimal result = calc.Calculate(2.5m, 0m, Calculator.models.CalculationType.DIVISTION);
 }
コード例 #8
0
 public void TestAddition()
 {
     Calculator.models.Calculator calc = new Calculator.models.Calculator();
     Assert.AreEqual(calc.Calculate(2.2m, 1.1m, Calculator.models.CalculationType.ADDITION), 3.3m);
     Assert.AreEqual(calc.Calculate(2.2m, -1.1m, Calculator.models.CalculationType.ADDITION), 1.1m);
 }
コード例 #9
0
 public void TestMultiplication()
 {
     Calculator.models.Calculator calc = new Calculator.models.Calculator();
     Assert.AreEqual(calc.Calculate(2.0m, 2.0m, Calculator.models.CalculationType.MULTIPLICATION), 4.0m);
 }
コード例 #10
0
 public void TestSubtraction()
 {
     Calculator.models.Calculator calc = new Calculator.models.Calculator();
     Assert.AreEqual(calc.Calculate(2.2m, 1.1m, Calculator.models.CalculationType.SUBTRACTION), 1.1m);
     Assert.AreEqual(calc.Calculate(2.2m, -1.1m, Calculator.models.CalculationType.SUBTRACTION), 3.3m);
 }