Пример #1
0
        public void Test_Equals_No_Rhs()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(3);
            calculator.OperationEntered("+");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("6", result);
        }
Пример #2
0
        public void Test_Plus_Minus_Sets_Rhs()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(4.0);
            calculator.OperationEntered("+");
            calculator.OperationEntered("plus_minus");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("0", result);
        }
Пример #3
0
        public void Test_Square_Root_Sets_Rhs()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(4.0);
            calculator.OperationEntered("+");
            calculator.OperationEntered("square_root");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("6", result);
        }
Пример #4
0
        public void Test_Rhs_Plus_Minus()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(10.04);
            calculator.OperationEntered("/");
            calculator.NumberEntered(4.0);
            string result = calculator.OperationEntered("plus_minus");

            Assert.AreEqual("-4", result);
        }
Пример #5
0
        public void Test_Reciprocal_Sets_Rhs()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(4.0);
            calculator.OperationEntered("+");
            calculator.OperationEntered("reciprocal");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("4.25", result);
        }
Пример #6
0
        public void Test_Rhs_Square_Root()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(10.04);
            calculator.OperationEntered("/");
            calculator.NumberEntered(4.0);
            string result = calculator.OperationEntered("squaRE_root");

            Assert.AreEqual("2", result);
        }
Пример #7
0
        public void Test_Calculator_Division()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(10.04);
            calculator.OperationEntered("/");
            calculator.NumberEntered(4.0);
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("2.51", result);
        }
Пример #8
0
        public void Test_Calculator_Multiplication()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(2.51);
            calculator.OperationEntered("*");
            calculator.NumberEntered(4.0);
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("10.04", result);
        }
Пример #9
0
        public void Test_Calculator_Subtraction()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(3.3);
            calculator.OperationEntered("-");
            calculator.NumberEntered(2.2);
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("1.1", result);
        }
Пример #10
0
        public void Test_Calculator_Addition()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(1.1);
            calculator.OperationEntered("+");
            calculator.NumberEntered(2.1);
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("3.2", result);
        }
Пример #11
0
        public void Test_Add_Reciprocal()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(1.76);
            calculator.OperationEntered("+");
            calculator.NumberEntered(4.0);
            calculator.OperationEntered("reciprocal");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("2.01", result);
        }
Пример #12
0
        public void Test_Calculator_Change_Operator()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(10.04);
            calculator.OperationEntered("/");
            calculator.OperationEntered("*");
            calculator.NumberEntered(4.0);
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("40.16", result);
        }
Пример #13
0
        public void Test_Repeat_Equals()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(1.0);
            calculator.OperationEntered("+");
            calculator.NumberEntered(4.0);
            calculator.OperationEntered("=");
            string result = calculator.OperationEntered("=");

            Assert.AreEqual("9", result);
        }
Пример #14
0
        public void Test_OperationEntered_binary()
        {
            string operation = "+";

            Logic.Calculator calculator = new Logic.Calculator();
            string           result     = calculator.OperationEntered(operation);

            Assert.AreEqual("+", result);
        }
Пример #15
0
        public void Test_OperationEntered_unary()
        {
            string operation = "reciprocal";

            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(4);
            string result = calculator.OperationEntered(operation);

            Assert.AreEqual("0.25", result);
        }
Пример #16
0
        public void Test_Reciprocal_After_Equals()
        {
            Logic.Calculator calculator = new Logic.Calculator();
            calculator.NumberEntered(1.0);
            calculator.OperationEntered("+");
            calculator.NumberEntered(3.0);
            calculator.OperationEntered("=");
            calculator.OperationEntered("=");
            calculator.OperationEntered("=");
            calculator.OperationEntered("=");
            calculator.OperationEntered("=");
            string result = calculator.OperationEntered("reciprocal");

            Assert.AreEqual("0.0625", result);
        }