Esempio n. 1
0
        public void CalculateADivision()
        {
            var calculator = new Calculator();
            var result     = calculator.Calculate("10/5", CalculatorShould.ConstructDictionary());

            Check.That(result).IsEqualTo(2);
        }
Esempio n. 2
0
        public void CalculateAMultipleSubastraction()
        {
            var calculator = new Calculator();
            var result     = calculator.Calculate("1-2,3-7", CalculatorShould.ConstructDictionary());

            Check.That(result).IsEqualTo(-8.3);
        }
Esempio n. 3
0
        public void CalculateAMultipleSum()
        {
            var calculator = new Calculator();
            var result     = calculator.Calculate("1+2,3+5.5", CalculatorShould.ConstructDictionary());

            Check.That(result).IsEqualTo(8.8);
        }
Esempio n. 4
0
        public void CalculateAMultipleMultiplication()
        {
            var calculator = new Calculator();
            var result     = calculator.Calculate("2*3*5", CalculatorShould.ConstructDictionary());

            Check.That(result).IsEqualTo(30);
        }
Esempio n. 5
0
        public void CalculateANonOperation()
        {
            var calculator = new Calculator();

            try
            {
                calculator.Calculate("10,0", CalculatorShould.ConstructDictionary());
                Assert.Fail("Expected exception");
            }
            catch (NoneOperatorException)
            {
                // Expected
            }
        }
Esempio n. 6
0
        public void CalculateADivisionByZero()
        {
            var calculator = new Calculator();

            try
            {
                calculator.Calculate("10/0", CalculatorShould.ConstructDictionary());
                Assert.Fail("Expected exception");
            }
            catch (DivideByZeroException)
            {
                // Expected
            }
        }
Esempio n. 7
0
        public void CalculateWithMultipleOperators()
        {
            var calculator = new Calculator();

            try
            {
                calculator.Calculate("10+5-2", CalculatorShould.ConstructDictionary());
                Assert.Fail("Expected exception");
            }
            catch (MultipleOperatorsException)
            {
                // Expected
            }
        }