Example #1
0
        public void TestMethod_Init()
        {
            CalcServicesApi api = new CalcServicesApi();

            Assert.IsTrue( api.STATEMENT.Equals(""));
            Assert.IsTrue( api.EDIT.Equals("0"));
        }
Example #2
0
        public void TestMethod_ClearEditNumber()
        {
            CalcServicesApi api = new CalcServicesApi();
            var obj = new PrivateObject(api);

            obj.SetField("statement", "11+22-");
            obj.SetField("editNumber", "120");

            obj.Invoke("ClearEditNumber");

            Assert.IsTrue(api.STATEMENT.Equals("11+22-"));
            Assert.IsTrue(api.EDIT.Equals("0"));
        } 
Example #3
0
        public void TestMethod_InputNum()
        {
            CalcServicesApi api = new CalcServicesApi();

            api.inputNum('0');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("0"));
            
            api.inputNum('1');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("1"));

            api.inputNum('2');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("12"));

            api.inputNum('3');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("123"));

            api.inputNum('4');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("1234"));
 
            api.inputNum('5');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("12345"));

            api.inputNum('6');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("123456"));

            api.inputNum('7');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("1234567"));

            api.inputNum('8');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("12345678"));

            api.inputNum('9');
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("123456789"));
        }
Example #4
0
        public void TestMethod_InputOperator()
        {
            CalcServicesApi api = new CalcServicesApi();

            api.inputOperator('+');

            Assert.IsTrue(api.STATEMENT.Equals("0+"));
            Assert.IsTrue(api.EDIT.Equals("0"));

            api.inputNum('1');
            Assert.IsTrue(api.STATEMENT.Equals("0+"));
            Assert.IsTrue(api.EDIT.Equals("1"));

            api.inputOperator('*');
            Assert.IsTrue(api.STATEMENT.Equals("0+1*"));
            Assert.IsTrue(api.EDIT.Equals("0"));

            api.inputNum('9');
            api.inputOperator('-');
            Assert.IsTrue(api.STATEMENT.Equals("0+1*9-"));
            Assert.IsTrue(api.EDIT.Equals("0"));

            api.inputNum('5');
            api.inputOperator('/');
            Assert.IsTrue(api.STATEMENT.Equals("0+1*9-5/"));
            Assert.IsTrue(api.EDIT.Equals("0"));
        }
Example #5
0
        public void TestMethod_inputClearAll()
        {
            CalcServicesApi api = new CalcServicesApi();
            var obj = new PrivateObject(api);

            obj.SetField("statement", "120+");
            obj.SetField("editNumber", "100");

            api.inputClearAll();

            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("0"));

            api.inputClearAll();
            Assert.IsTrue(api.STATEMENT.Equals(""));
            Assert.IsTrue(api.EDIT.Equals("0"));
        }