예제 #1
0
        public void TestXml() {
            var xml = @"
    <cfg>
        <strings>
            <add value='1' />
            <add value='2' />
            <add value='3' />
        </strings>
    </cfg>
".Replace("'", "\"");

            var cfg = new Los(xml);

            foreach (var problem in cfg.Errors()) {
                Console.WriteLine(problem);
            }

            var problems = cfg.Errors();
            Assert.AreEqual(0, problems.Length);
            Assert.AreEqual(3, cfg.Strings.Count);

        }
예제 #2
0
        public void TestJson() {
            var json = @"
    {
        'strings': [
            { 'value':'1' },
            { 'value':'2' },
            { 'value':'3' }
        ]
    }
".Replace("'", "\"");

            var cfg = new Los(json);

            foreach (var problem in cfg.Errors()) {
                Console.WriteLine(problem);
            }

            var problems = cfg.Errors();
            Assert.AreEqual(0, problems.Length);
            Assert.AreEqual(3, cfg.Strings.Count);

        }
예제 #3
0
        public void TestXml() {
            var xml = @"
    <cfg>
        <numbers>
            <add>
                <inner-numbers>
                    <add x='1' />
                    <add y='5' />
                    <add z='10' />
                </inner-numbers>
            </add>
        </numbers>
    </cfg>
".Replace("'", "\"");

            var cfg = new Los(xml);

            foreach (var problem in cfg.Errors()) {
                Console.WriteLine(problem);
            }

            var problems = cfg.Errors();
            Assert.AreEqual(0, problems.Length);
            Assert.AreEqual(0, cfg.Strings.Count);
            Assert.AreEqual(1, cfg.Numbers.Count);
            Assert.AreEqual(3, cfg.Numbers[0].InnerNumbers.Count);
            Assert.AreEqual(1, cfg.Numbers[0].InnerNumbers[0]);
            Assert.AreEqual(5, cfg.Numbers[0].InnerNumbers[1]);
            Assert.AreEqual(10, cfg.Numbers[0].InnerNumbers[2]);

        }
예제 #4
0
        public void TestJsonArray() {
            var json = @"{
        'numbers':[
            { 'inner-numbers': [ 1, 5, 10 ] }
        ]
    }
".Replace("'", "\"");

            var cfg = new Los(json);

            foreach (var problem in cfg.Errors()) {
                Console.WriteLine(problem);
            }

            var problems = cfg.Errors();
            Assert.AreEqual(0, problems.Length);
            Assert.AreEqual(0, cfg.Strings.Count);
            Assert.AreEqual(1, cfg.Numbers.Count);
            Assert.AreEqual(3, cfg.Numbers[0].InnerNumbers.Count);
            Assert.AreEqual(1, cfg.Numbers[0].InnerNumbers[0]);
            Assert.AreEqual(5, cfg.Numbers[0].InnerNumbers[1]);
            Assert.AreEqual(10, cfg.Numbers[0].InnerNumbers[2]);

        }