Ejemplo n.º 1
0
        public void ExecuteCmd_Test()
        {
            Sheet      sheet  = new Sheet();
            SumCommand cmd    = new SumCommand(sheet);
            bool       result = false;

            CreateCommand createCmd = new CreateCommand(sheet);

            result = createCmd.AnalysisCmd("C 3 3");
            Assert.AreEqual(result, true);
            createCmd.ExecuteCmd();
            Assert.AreEqual(result, true);

            SetNumCommand setCmd = new SetNumCommand(sheet);

            result = setCmd.AnalysisCmd("N 1 1 100");
            Assert.AreEqual(result, true);
            result = setCmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 1, sheet._printArr), 100);

            result = setCmd.AnalysisCmd("N 1 2 200");
            Assert.AreEqual(result, true);
            result = setCmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 2, sheet._printArr), 200);

            result = cmd.AnalysisCmd("S 1 1 1 2 1 3");
            Assert.AreEqual(result, true);
            result = cmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 3, sheet._printArr), 300);

            Console.WriteLine("Test Complete");
        }
Ejemplo n.º 2
0
        public void ExecuteCmd_Test_Error2()
        {
            Sheet      sheet  = new Sheet();
            SumCommand cmd    = new SumCommand(sheet);
            bool       result = false;

            try
            {
                result = cmd.AnalysisCmd("S 1 1 1 2 2 2");
                Assert.AreEqual(result, true);
                result = cmd.ExecuteCmd();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Please Creaet Table First!", ex.Message);
            }

            CreateCommand createCmd = new CreateCommand(sheet);

            result = createCmd.AnalysisCmd("C 3 3");
            Assert.AreEqual(result, true);
            createCmd.ExecuteCmd();
            Assert.AreEqual(result, true);

            SetNumCommand setCmd = new SetNumCommand(sheet);

            result = setCmd.AnalysisCmd("N 1 1 100");
            Assert.AreEqual(result, true);
            result = setCmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 1, sheet._printArr), 100);

            result = setCmd.AnalysisCmd("N 1 2 200");
            Assert.AreEqual(result, true);
            result = setCmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 2, sheet._printArr), 200);

            result = cmd.AnalysisCmd("S 1 1 1 2 1 3");
            Assert.AreEqual(result, true);
            result = cmd.ExecuteCmd();
            Assert.AreEqual(result, true);
            Assert.AreEqual(CommonHelper.GetNumberValue(1, 3, sheet._printArr), 300);

            try
            {
                result = cmd.AnalysisCmd("S 1 9 1 2 2 2");
                Assert.AreEqual(result, true);
                result = cmd.ExecuteCmd();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Please enter a valid subscript.", ex.Message);


                Console.WriteLine("Test Complete");
            }
        }
Ejemplo n.º 3
0
        public void ExecuteCmd_Test_Error2()
        {
            bool          result    = false;
            Sheet         sheet     = new Sheet();
            CreateCommand createCmd = new CreateCommand(sheet);

            result = createCmd.AnalysisCmd("C 3 3");
            Assert.AreEqual(result, true);
            result = createCmd.ExecuteCmd();
            Assert.AreEqual(result, true);

            SetNumCommand cmd = new SetNumCommand(sheet);

            try
            {
                result = cmd.AnalysisCmd("N 1 9 333");
                Assert.AreEqual(result, true);
                result = cmd.ExecuteCmd();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Please enter a valid subscript.", ex.Message);
            }
            Console.WriteLine("Test Complete");
        }
Ejemplo n.º 4
0
        public void ExecuteCmd_Test_Error1()
        {
            Sheet         sheet  = new Sheet();
            SetNumCommand cmd    = new SetNumCommand(sheet);
            bool          result = false;

            try
            {
                result = cmd.AnalysisCmd("N 1 3 333");
                Assert.AreEqual(result, true);
                result = cmd.ExecuteCmd();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Please Create Table First!", ex.Message);
            }
            Console.WriteLine("Test Complete");
        }
Ejemplo n.º 5
0
        public void ExecuteCmd_Test()
        {
            bool          result    = false;
            Sheet         sheet     = new Sheet();
            CreateCommand createCmd = new CreateCommand(sheet);

            result = createCmd.AnalysisCmd("C 3 3");
            Assert.AreEqual(result, true);
            result = createCmd.ExecuteCmd();
            Assert.AreEqual(result, true);

            SetNumCommand cmd = new SetNumCommand(sheet);

            result = cmd.AnalysisCmd("N 1 3 333");
            Assert.AreEqual(result, true);
            result = cmd.ExecuteCmd();
            Assert.AreEqual(result, true);

            Assert.AreEqual(CommonHelper.GetNumberValue(1, 3, sheet._printArr), 333);

            Console.WriteLine("Test Complete");
        }