示例#1
0
        public void TestJsonOutput()
        {
            CLCommand cmd = CLCommand.Create("CALL TEST 'VALUE' INVALID(*YES) DEBUG('NO')");

            Console.WriteLine(cmd.ToJson());
            Assert.Equal("{\"Name\":\"CALL\",\"Parameters\":[{\"Index\":1,\"Name\":\"*NONE\",\"Parameters\":[\"TEST\"],\"ParameterType\":3},{\"Index\":2,\"Name\":\"*NONE\",\"Parameters\":[\"VALUE\"],\"ParameterType\":2},{\"Index\":3,\"Name\":\"INVALID\",\"Parameters\":[\"*YES\"],\"ParameterType\":0},{\"Index\":4,\"Name\":\"DEBUG\",\"Parameters\":[\"NO\"],\"ParameterType\":1}]}", cmd.ToJson());
        }
示例#2
0
        public void TestParseCommandWithCarriageReturn()
        {
            CLCommand cmd = CLCommand.Create("CALL \r TEST \r");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("*NONE", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
        }
示例#3
0
        public void TestParseCommandWithManyBlanks02()
        {
            CLCommand cmd = CLCommand.Create("CALL     PGM(TEST)    ");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("PGM", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
        }
示例#4
0
        public void TestParseCommandWithoutParameterNameAndWithoutQuotationMarks()
        {
            CLCommand cmd = CLCommand.Create("CALL TEST");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("*NONE", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
        }
示例#5
0
        public void TestParseCommandWithParenthesesAndWithoutQuotationMarks()
        {
            CLCommand cmd = CLCommand.Create("CALL PGM(TEST)");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("PGM", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
        }
示例#6
0
        public void TestParseCommandWithMultipleParametersInParenthesesAndQuotationMarks()
        {
            CLCommand cmd = CLCommand.Create("CALL PGM('TEST') PARM('Just a test parameter!')");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("PGM", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
            Assert.Equal("PARM", cmd.Parameters[1].Name);
            Assert.Equal("Just a test parameter!", cmd.Parameters[1].Parameters[0]);
            Assert.Equal(2, cmd.Parameters[1].Index);
        }
示例#7
0
        public void TestParseCommandWithMultipleSubparameters()
        {
            CLCommand cmd = CLCommand.Create("TSTCMD RECT(2 6 1 7)");

            Assert.Equal("TSTCMD", cmd.Name);
            Assert.Equal("RECT", cmd.Parameters[0].Name);
            Assert.Equal("2", cmd.Parameters[0].Parameters[0]);
            Assert.Equal("6", cmd.Parameters[0].Parameters[1]);
            Assert.Equal("1", cmd.Parameters[0].Parameters[2]);
            Assert.Equal("7", cmd.Parameters[0].Parameters[3]);
            Assert.Equal(1, cmd.Parameters[0].Index);
        }
示例#8
0
        public void TestParseCommandWithMultipleParametersWithoutParameterName()
        {
            CLCommand cmd = CLCommand.Create("CALL 'TEST' 'This is a testvalue'");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("*NONE", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
            Assert.Equal("*NONE", cmd.Parameters[1].Name);
            Assert.Equal("This is a testvalue", cmd.Parameters[1].Parameters[0]);
            Assert.Equal(2, cmd.Parameters[1].Index);
        }
示例#9
0
        public void TestParseCommandWitMixedParameters()
        {
            CLCommand cmd = CLCommand.Create("CALL TEST 'VALUE' INVALID(*YES) DEBUG('NO')");

            Assert.Equal("CALL", cmd.Name);
            Assert.Equal("*NONE", cmd.Parameters[0].Name);
            Assert.Equal("TEST", cmd.Parameters[0].Parameters[0]);
            Assert.Equal(1, cmd.Parameters[0].Index);
            Assert.Equal("*NONE", cmd.Parameters[1].Name);
            Assert.Equal("VALUE", cmd.Parameters[1].Parameters[0]);
            Assert.Equal(2, cmd.Parameters[1].Index);
            Assert.Equal("INVALID", cmd.Parameters[2].Name);
            Assert.Equal("*YES", cmd.Parameters[2].Parameters[0]);
            Assert.Equal(3, cmd.Parameters[2].Index);
            Assert.Equal("DEBUG", cmd.Parameters[3].Name);
            Assert.Equal("NO", cmd.Parameters[3].Parameters[0]);
            Assert.Equal(4, cmd.Parameters[3].Index);
        }
示例#10
0
        public void TestParseCommandWithoutParameters()
        {
            CLCommand cmd = CLCommand.Create("CALL");

            Assert.Equal("CALL", cmd.Name);
        }