예제 #1
0
        public void Check_For_Divide_by_0()
        {
            int a = 1, b = 0;

            object result = CalcFunctions.Divide(a, b);

            Assert.AreEqual(result.ToString(), "DIV BY 0");
        }
예제 #2
0
        public void CalculateCurrentAnswerSyntaxErrorTest()
        {
            double currentAnswer    = 123.4;
            string currentInput     = "1,54,";
            string previousOperator = "+";

            CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator);
        }
예제 #3
0
        public void CalcFunctions_Subtract_Two_Double_Numbers()
        {
            double a = 2.393, b = 4.9393;

            double result = (double)CalcFunctions.Subtract(a, b);

            Assert.AreEqual(result, a - b);
        }
예제 #4
0
        public void CalcFunctions_Multiply_Two_Double_Numbers()
        {
            double a = 2.393, b = 4.9393;

            double result = (double)CalcFunctions.Multiply(a, b);

            Assert.AreEqual(result, a * b);
        }
예제 #5
0
        public void CalcFunctions_Divide_Two_Double_Numbers()
        {
            double a = 2.393, b = 4.9393;

            double result = (double)CalcFunctions.Divide(a, b);

            Assert.AreEqual(result, a / b);
        }
예제 #6
0
        public void CalcFunctions_Add_Two_Double_Numbers()
        {
            double a = 2.393, b = 4.9393;

            double result = (double)CalcFunctions.Add(a, b);

            Assert.AreEqual(result, a + b);
        }
예제 #7
0
        public void CalcFunctions_Subtract_Two_Numbers()
        {
            int a = 1, b = 2;

            int result = (int)CalcFunctions.Subtract(b, a);

            Assert.AreEqual(result, b - a);
        }
예제 #8
0
        public void CalcFunctions_Multiply_Two_Numbers()
        {
            int a = 2, b = 3;

            int result = (int)CalcFunctions.Multiply(a, b);

            Assert.AreEqual(result, a * b);
        }
예제 #9
0
        public void CalculateCurrentAnswerDivideByZeroTest()
        {
            double currentAnswer    = 123.4;
            string currentInput     = "0";
            string previousOperator = "/";

            CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator);
        }
예제 #10
0
        public void CalcFunctions_Subtract_Int_And_Double_Numbers()
        {
            double a = 12.392;
            int    b = 5;

            double result = (double)CalcFunctions.Subtract(a, b);

            Assert.AreEqual(result, a - b);
        }
예제 #11
0
        public void CalcFunctions_Add_Int_And_Double_Numbers()
        {
            double a = 32.32232;
            int    b = 5;

            double result = (double)CalcFunctions.Add(a, b);

            Assert.AreEqual(result, a + b);
        }
예제 #12
0
        public void Check_For_Integer_Underflow_Sub()
        {
            int a = Int32.MinValue;
            int b = 1;

            object result = CalcFunctions.Subtract(a, b);

            Assert.AreEqual(result.ToString(), "UNDERFLOW");
        }
예제 #13
0
        public void Check_For_Integer_Overflow_Add()
        {
            int a = Int32.MaxValue;
            int b = 1;

            object result = CalcFunctions.Add(a, b);

            Assert.AreEqual(result.ToString(), "OVERFLOW");
        }
예제 #14
0
        public void CalcFunctions_Divide_Int_Double_Numbers()
        {
            double a = 9.32314;
            int    b = 3;

            double result = (double)CalcFunctions.Divide(a, b);

            Assert.AreEqual(result, a / b);
        }
예제 #15
0
        public void CalcFunctions_Multiply_Int_And_Double_Numbers()
        {
            double a = 2.3939;
            int    b = 9;

            double result = (double)CalcFunctions.Multiply(a, b);

            Assert.AreEqual(result, a * b);
        }
예제 #16
0
        public void CalcFunctions_add_Two_Numbers()
        {
            //Arrange
            int a = 1, b = 2;

            //Act
            int result = (int)CalcFunctions.Add(a, b);

            //Assert
            Assert.AreEqual(result, a + b);
        }
예제 #17
0
        public void CalculateCurrentAnswerTest()
        {
            double currentAnswer    = 123.4;
            string currentInput     = "1";
            string previousOperator = "+";

            currentAnswer = CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator).Item2;
            Assert.AreEqual(124.4, currentAnswer);
            currentInput     = "1,4";
            previousOperator = "-";
            currentAnswer    = CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator).Item2;
            Assert.AreEqual(123, currentAnswer);
            currentInput     = "2";
            previousOperator = "*";
            currentAnswer    = CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator).Item2;
            Assert.AreEqual(246, currentAnswer);
            currentInput     = "2";
            previousOperator = "/";
            currentAnswer    = CalcFunctions.CalculateCurrentAnswer(currentAnswer, currentInput, previousOperator).Item2;
            Assert.AreEqual(123, currentAnswer);
        }