コード例 #1
0
        public void TestJson()
        {
            var json = @"{
        'things':[
            { 'value':5, 'longValue':5, 'stringValue':'1' },
            { 'value':10, 'longValue':10, 'stringValue':'2' },
            { 'value':15, 'longValue':15, 'stringValue':'6' }
        ]
    }
".Replace("'", "\"");

            var cfg = new TestValue(json);

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

            var problems = cfg.Errors();

            Assert.AreEqual(3, problems.Length);
            Assert.IsTrue(problems[0] == "The value value 5 is too small. The minimum value allowed is 6.");
            Assert.IsTrue(problems[1] == "The longvalue value 5 is too small. The minimum value allowed is 6.");
            Assert.IsTrue(problems[2] == "The stringvalue value 6 is too big. The maximum value allowed is 5.");
        }
コード例 #2
0
        public void TestXml()
        {
            var xml = @"
    <test>
        <things>
            <add value='5' longValue='5' stringValue='1' />
            <add value='10' longValue='10' stringValue='2'/>
            <add value='15' longValue='15' stringValue='6'/>
            <add value='10' longValue='10' stringValue='&quot;10&quot;' />
        </things>
    </test>
".Replace("'", "\"");

            var cfg = new TestValue(xml);

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

            var problems = cfg.Errors();

            Assert.AreEqual(4, problems.Length);
            Assert.IsTrue(problems[0] == "The value value 5 is too small. The minimum value allowed is 6.");
            Assert.IsTrue(problems[1] == "The longvalue value 5 is too small. The minimum value allowed is 6.");
            Assert.IsTrue(problems[2] == "The stringvalue value 6 is too big. The maximum value allowed is 5.");
            Assert.IsTrue(problems[3] == "The stringvalue value \"10\" is too small. The minimum value allowed is 1.");
        }
コード例 #3
0
ファイル: Value.cs プロジェクト: modulexcite/Cfg-NET
        public void TestXml() {
            var xml = @"
    <test>
        <things>
            <add value='5' longValue='5' stringValue='1' />
            <add value='10' longValue='10' stringValue='2'/>
            <add value='15' longValue='15' stringValue='6'/>
            <add value='10' longValue='10' stringValue='&quot;10&quot;' />
        </things>
    </test>
".Replace("'", "\"");

            var cfg = new TestValue(xml);

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

            var problems = cfg.Errors();
            Assert.AreEqual(4, problems.Length);
            Assert.IsTrue(problems[0] == "The 'value' attribute value '5' is too small. The minimum value allowed is '6'.");
            Assert.IsTrue(problems[1] == "The 'longvalue' attribute value '5' is too small. The minimum value allowed is '6'.");
            Assert.IsTrue(problems[2] == "The 'stringvalue' attribute value '6' is too big. The maximum value allowed is '5'.");
            Assert.IsTrue(problems[3] == "The 'stringvalue' attribute value '\"10\"' is too small. The minimum value allowed is '1'.");

        }
コード例 #4
0
ファイル: Value.cs プロジェクト: modulexcite/Cfg-NET
        public void TestJson() {
            var json = @"{
        'things':[
            { 'value':5, 'longValue':5, 'stringValue':'1' },
            { 'value':10, 'longValue':10, 'stringValue':'2' },
            { 'value':15, 'longValue':15, 'stringValue':'6' }
        ]
    }
".Replace("'", "\"");

            var cfg = new TestValue(json);

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

            var problems = cfg.Errors();
            Assert.AreEqual(3, problems.Length);
            Assert.IsTrue(problems[0] == "The 'value' attribute value '5' is too small. The minimum value allowed is '6'.");
            Assert.IsTrue(problems[1] == "The 'longvalue' attribute value '5' is too small. The minimum value allowed is '6'.");
            Assert.IsTrue(problems[2] == "The 'stringvalue' attribute value '6' is too big. The maximum value allowed is '5'.");

        }