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

            Check.That(result).IsEqualTo(2);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #4
0
        public void CalculateAMultipleMultiplication()
        {
            var calculator = new Calculator();
            var result     = calculator.Calculate("2*3*5", CalculatorShould.ConstructDictionary());

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

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

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

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