Ejemplo n.º 1
0
        public void integerParameter(String input, String expected)
        {
            String source = @"- readString: ""My Text\nGoes\nHere\nand is\nmulti line\n""                            
- {0}
";

            source = String.Format(source, input);
            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 2
0
        public void dictionaryParametersDefaults()
        {
            const String source   = @"
- readString: 'Mx trx miscarrx. Shx flx.'
- sed: { 'pattern': 'x', 'replacement': 'y' }
";
            const String expected = "My trx miscarrx. Shx flx.";

            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 3
0
        public void helloWorld()
        {
            const String source   = @"
# echo 'Hello world'
- readString: Hello World
";
            const String expected = "Hello World";

            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 4
0
        public void sequenceParametersDefaults()
        {
            const String source   = @"
- readString: 'Mx trx miscarrx. Shx flx.'
- sed: ['x','y']
";
            const String expected = "My trx miscarrx. Shx flx.";

            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 5
0
        public void multiParameters(String input, String expected)
        {
            String source = @"- readString: ""a\nb\tc\n""
- parseTab: 
- {0}
";

            source = String.Format(source, input);
            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 6
0
        public void booleanParameter(String input, String expected)
        {
            String source = @"- readString: ""a\tb\nc\td\n""
- {0}
- sed: ['.*', 'x\0x']
- print: $2|$1
";

            source = String.Format(source, input);
            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 7
0
        public void blockSingle()
        {
            const String source   = @"
- cat: 
    block:
      - readString: Line One
      - readString: Line Two
";
            const String expected =
                @"Line One
Line Two";

            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 8
0
        public void multiObject(String input, String expected)
        {
            String source = @"- readString: ""head1\thead2\na1\ta2\n""
- parseTab: true 
- {0}
";

            source = String.Format(source, input);
            if (expected == null)
            {
                Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source));
            }
            else
            {
                CmdTestUtil.verifyYaml(source, expected);
            }
        }
Ejemplo n.º 9
0
        public void sequenceParameters()
        {
            String       source   = @"
- readString: 'Mx trx miscarrx.
  Shx flx.'
- sed:
  - x
  - y
  - ig  
";
            const String expected = "My try miscarry. Shy fly.";

            CmdTestUtil.verifyYaml(source, expected);

            source = @"
- readString: 'Mx trx miscarrx. Shx flx.'
- sed: ['x','y','ig']
";
            CmdTestUtil.verifyYaml(source, expected);
        }
Ejemplo n.º 10
0
        public void sequenceParametersTooMany()
        {
            const String             source = @"[{'readString': 'Mx trx miscarrx. Shx flx.'}, {'sed': ['w','x','y','z']}]";
            InvalidArgumentException error  = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source));

            Assert.Equal("Too many parameters 4 specified for Pnyx method 'sed', which only has 3 parameters", error.Message);
        }
Ejemplo n.º 11
0
        public void unknownMethod()
        {
            const String             source = @"- junk:";
            InvalidArgumentException error  = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source));

            Assert.Equal("Pnyx method can not be found: junk", error.Message);
        }
Ejemplo n.º 12
0
        public void dictionaryParametersTooMany()
        {
            const String             source = @"
- readString: 'Mx trx miscarrx. Shx flx.'
- sed: { 'flags': 'ig', 'pattern': 'x', 'replacement': 'y', 'junk': 'xxx' }
";
            InvalidArgumentException error  = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source));

            Assert.Equal("Unknown named parameters 'junk' for Pnyx method 'sed', which has parameters 'pattern,replacement,flags'", error.Message);
        }
Ejemplo n.º 13
0
        public void dictionaryParametersMissingRequired()
        {
            const String             source = @"
- readString: 'Mx trx miscarrx. Shx flx.'
- sed: { 'pattern': 'x' }
";
            InvalidArgumentException error  = Assert.Throws <InvalidArgumentException>(() => CmdTestUtil.verifyYaml(source));

            Assert.Equal("Pnyx method 'sed' is missing required parameter 'replacement'", error.Message);
        }