Esempio n. 1
0
        private static void Test4SumCommand()
        {
            CommandDispatcher commandDispatcher = new CommandDispatcher();
            string            message;

            // Cover the @"^ct\d{1,w} \d{1,h}(?: \d{1,w} \d{1,h}){2}$" in VerificationExpression of SumCommand and the Illustration
            Console.WriteLine("Test for a mere command tag:");
            commandDispatcher.CheckInputToDispatch(SumCommand.Command_Tag, out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}(?: \d{1,w} \d{1,h}){2}$" in VerificationExpression of SumCommand and the Illustration
            Console.WriteLine("Test for non-numbers:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}a b c d e f", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}(?: \d{1,w} \d{1,h}){2}$" in VerificationExpression of SumCommand and the Illustration
            Console.WriteLine("Test for insufficient parameters:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 2", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}(?: \d{1,w} \d{1,h}){2}$" in VerificationExpression of SumCommand and the Illustration
            Console.WriteLine("Test for redundant parameters:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 2 3 3 4 4", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}(?: \d{1,w} \d{1,h}){2}$" in VerificationExpression of SumCommand and the Illustration
            Console.WriteLine("Test for negative position:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}-1 -1 -1 -1 -1 -1", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet == null)" in Execute() of SumCommand
            Console.WriteLine("Test for performing sum without creating spreadsheet first:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 2 3 3", out message);
            Console.WriteLine(message);

            const int mTest_Width  = 20;
            const int mTest_Height = 10;

            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{mTest_Width} {mTest_Height}", out message);
            // Input numbers forming a 3*3 matrix.
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 1 1", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}2 1 2", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}3 1 3", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 2 2", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}2 2 4", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}3 2 6", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 3 3", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}2 3 6", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}3 3 9", out message);

            // Cover "if (x < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero x1:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}0 0 0 0 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (y < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero y1:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 0 0 0 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (x < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero x2:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 0 0 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (y < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero y2:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 0 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (x < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero x3:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 2 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (y < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero y3:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 2 2 3 0", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(0) + 1 < x)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for x1 greater than the maximum width:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}{mTest_Width + 1} {mTest_Height / 2} 3 3 4 4", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(1) + 1 < y)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for y1 greater than the maximum height:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}{mTest_Width / 2} {mTest_Height + 1} 3 3 4 4", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(0) + 1 < x)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for x2 greater than the maximum width:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 {mTest_Width + 1} {mTest_Height / 2} 4 4", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(1) + 1 < y)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for y2 greater than the maximum height:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 {mTest_Width / 2} {mTest_Height + 1} 4 4", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(0) + 1 < x)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for x3 greater than the maximum width:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 3 3 {mTest_Width + 1} {mTest_Height / 2}", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(1) + 1 < y)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for y3 greater than the maximum height:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 3 3 {mTest_Width / 2} {mTest_Height + 1}", out message);
            Console.WriteLine(message);

            // Cover "if (1 <= x && x <= spreadsheet.GetUpperBound(0) + 1 && 1 <= y && y <= spreadsheet.GetUpperBound(1) + 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for (x3,y3) out of the range from (x1,y1) to (x2,y2):");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 3 3 4 4", out message);
            Console.WriteLine(message);

            // Cover "if (1 <= x && x <= spreadsheet.GetUpperBound(0) + 1 && 1 <= y && y <= spreadsheet.GetUpperBound(1) + 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for (x3,y3) in the range from (x1,y1) to (x2,y2):");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 3 3 2 2", out message);
            Console.WriteLine(message);

            // Cover "if (minValue <= value && value <= maxValue)" in CheckValueValid() of CommandBase
            Console.WriteLine("Test for (x1,y1) equal to (x2,y2):");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 1 1 4 4", out message);
            Console.WriteLine(message);

            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}2 2 4", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}4 4 {mMin_Value}", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}5 5 -1", out message);

            // Cover "if (value < minValue)" in CheckValueValid() of CommandBase
            Console.WriteLine("Test for the sum underflowed:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}4 4 5 5 6 6", out message);
            Console.WriteLine(message);

            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}4 4 {mMax_Value}", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}5 5 1", out message);

            // Cover "if (maxValue < value)" in CheckValueValid() of CommandBase
            Console.WriteLine("Test for the sum overflowed:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}4 4 5 5 6 6", out message);
            Console.WriteLine(message);

            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}4 4 0", out message);
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}5 5 0", out message);

            // Cover "if (minValue <= value && value <= maxValue)" in CheckValueValid() of CommandBase
            Console.WriteLine("Test for some empty cells:");
            commandDispatcher.CheckInputToDispatch($"{SumCommand.Command_Tag}1 1 5 5 6 6", out message);
            Console.WriteLine(message);
        }
Esempio n. 2
0
        private static void Test4CreateCommand()
        {
            CommandDispatcher commandDispatcher = new CommandDispatcher();
            string            message;

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand
            Console.WriteLine("Test for a mere command tag:");
            commandDispatcher.CheckInputToDispatch(CreateCommand.Command_Tag, out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand and the Illustration
            Console.WriteLine("Test for insufficient parameters:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}1", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand and the Illustration
            Console.WriteLine("Test for redundant parameters:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}1 1 1", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand and the Illustration
            Console.WriteLine("Test for non-numbers:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}a b", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand and the Illustration
            Console.WriteLine("Test for negative width and height:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}-1 -1", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h}$" in VerificationExpression of CreateCommand and the Illustration
            Console.WriteLine("Test for too more bits of width and height:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}100 100", out message);
            Console.WriteLine(message);

            // Cover "if (width < Min_Width)" in Execute() of CreateCommand
            Console.WriteLine("Test for width less than the minimun width:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{CreateCommand.Min_Width - 1} 10", out message);
            Console.WriteLine(message);

            // Cover "if (Max_Width < width)" in Execute() of CreateCommand
            Console.WriteLine("Test for width greater than the maximum width:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{CreateCommand.Max_Width + 1} 10", out message);
            Console.WriteLine(message);

            // Cover "if (height < Min_Height)" in Execute() of CreateCommand
            Console.WriteLine("Test for height less than the minimun height:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}20 {CreateCommand.Min_Height - 1}", out message);
            Console.WriteLine(message);

            // Cover "if (Max_Height < height)" in Execute() of CreateCommand
            Console.WriteLine("Test for height greater than the maximum height:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}20 {CreateCommand.Max_Height + 1}", out message);
            Console.WriteLine(message);

            // Cover "if (Min_Width <= width && width <= Max_Width)" and "if (Min_Height <= height && height <= Max_Height)" in Execute() of CreateCommand
            Console.WriteLine("Test for the minimum values:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{CreateCommand.Min_Width} {CreateCommand.Min_Height}", out message);
            Console.WriteLine(message);

            // Cover "if (Min_Width <= width && width <= Max_Width)" and "if (Min_Height <= height && height <= Max_Height)" in Execute() of CreateCommand
            Console.WriteLine("Test for the maximum values:");
            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{CreateCommand.Max_Width} {CreateCommand.Max_Height}", out message);
            Console.WriteLine(message);
        }
Esempio n. 3
0
        private static void Test4NumberCommand()
        {
            CommandDispatcher commandDispatcher = new CommandDispatcher();
            string            message;

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine("Test for a mere command tag:");
            commandDispatcher.CheckInputToDispatch(NumberCommand.Command_Tag, out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine("Test for non-numbers:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}a b c", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine("Test for insufficient parameters:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 1", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine("Test for redundant parameters:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 1 1 1", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet == null)" in Execute() of NumberCommand
            Console.WriteLine("Test for inputing number without creating spreadsheet first:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 1 1", out message);
            Console.WriteLine(message);

            commandDispatcher.CheckInputToDispatch($"{CreateCommand.Command_Tag}{mTest_Width} {mTest_Height}", out message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine("Test for negative position:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}-1 -1 -1", out message);
            Console.WriteLine(message);

            // Cover "if (x < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero x1:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}0 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (y < 1)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for zero y1:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 0 0", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(0) + 1 < x)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for x1 greater than the maximum width:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}{mTest_Width + 1} {mTest_Height / 2} 0", out message);
            Console.WriteLine(message);

            // Cover "if (spreadsheet.GetUpperBound(1) + 1 < y)" in CheckPositionValid() of CommandBase
            Console.WriteLine("Test for y1 greater than the maximum height:");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}{mTest_Width / 2} {mTest_Height + 1} 0", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine($"Test for v1({mMin_Value - 1}) less than the minimum value({mMin_Value}):");
            string command = $"{NumberCommand.Command_Tag}1 2 {mMin_Value - 1}";

            commandDispatcher.CheckInputToDispatch(command, out message);
            Console.WriteLine(message);

            // Cover "if (minValue <= value && value <= maxValue)" in CheckValueValid() of CommandBase
            Console.WriteLine($"Test for v1 equal to the minimum value({mMin_Value}):");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}1 3 {mMin_Value}", out message);
            Console.WriteLine(message);

            // Cover the @"^ct\d{1,w} \d{1,h} -?\d{1,2}$" in VerificationExpression of NumberCommand and the Illustration
            Console.WriteLine($"Test for v1({mMax_Value + 1}) greater than the maximum value({mMax_Value}):");
            command = $"{NumberCommand.Command_Tag}2 1 {mMax_Value + 1}";
            commandDispatcher.CheckInputToDispatch(command, out message);
            Console.WriteLine(message);

            // Cover "if (minValue <= value && value <= maxValue)" in CheckValueValid() of CommandBase
            Console.WriteLine($"Test for v1 equal to the maximum value({mMax_Value}):");
            commandDispatcher.CheckInputToDispatch($"{NumberCommand.Command_Tag}2 2 {mMax_Value}", out message);
            Console.WriteLine(message);
        }