Exemple #1
0
        public void SingleSubtractionNegativeResult()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "5-8";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, -3);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #2
0
        public void SingleMultiplicationPositives()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "5*8";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, 40);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #3
0
        public void SingleDivisionOneNegatives()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "40/-8";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, -5);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #4
0
        public void AdditionOfTwoNegativeValues()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "-8+-3";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, -11);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #5
0
        public void DecimalNoLeadingNumber()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = ".5/-.25";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, -2);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #6
0
        public void SingleAdditionPositiveResult()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "-3.5+4.5";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, 1);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #7
0
        public void MassOrderOfOperations()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "3+4*(5+20)/5*2";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, 43);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #8
0
        public void Brackets()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "(5+20)/5";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, 5);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }
Exemple #9
0
        public void DivisionAndAddition()
        {
            // SETUP
            var calc  = new Calculator_Core();
            var input = "-3+20/-5";
            Tuple <string, double> expectedResult = new Tuple <string, double>(input, -7);

            // EXECUTE
            var result = calc.CalculateFromString(input);

            // ASSERT
            Assert.AreEqual(expectedResult, result);
        }