Example #1
0
        public void TestXml()
        {
            var xml = @"
    <test>
        <things>
            <add value='too-short' />
            <add value='this-is-way-too-long' />
            <add value='just-right' />
        </things>
    </test>
".Replace("'", "\"");

            var cfg = new TestLength(xml);

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

            var problems = cfg.Errors();

            Assert.AreEqual(2, problems.Length);
            Assert.IsTrue(problems[0] == "The value too-short is too short. It is 9 characters. It must be at least 10 characters.");
            Assert.IsTrue(problems[1] == "The value this-is-way-too-long is too long. It is 20 characters. It must not exceed 15 characters.");
        }
Example #2
0
        public void TestJson() {
            var json = @"{
        'things':[
            { 'value':'too-short' },
            { 'value':'this-is-way-too-long' },
            { 'value':'just-right' }
        ]
    }
".Replace("'", "\"");

            var cfg = new TestLength(json);

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

            var problems = cfg.Errors();
            Assert.AreEqual(2, problems.Length);
            Assert.IsTrue(problems[0] == "The 'value' attribute value 'too-short' is too short. It is 9 characters. It must be at least 10 characters.");
            Assert.IsTrue(problems[1] == "The 'value' attribute value 'this-is-way-too-long' is too long. It is 20 characters. It must not exceed 15 characters.");

        }
Example #3
0
        public void TestXml() {
            var xml = @"
    <test>
        <things>
            <add value='too-short' />
            <add value='this-is-way-too-long' />
            <add value='just-right' />
        </things>
    </test>
".Replace("'", "\"");

            var cfg = new TestLength(xml);

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

            var problems = cfg.Errors();
            Assert.AreEqual(2, problems.Length);
            Assert.IsTrue(problems[0] == "The 'value' attribute value 'too-short' is too short. It is 9 characters. It must be at least 10 characters.");
            Assert.IsTrue(problems[1] == "The 'value' attribute value 'this-is-way-too-long' is too long. It is 20 characters. It must not exceed 15 characters.");

        }
Example #4
0
        public void TestJson()
        {
            var json = @"{
        'things':[
            { 'value':'too-short' },
            { 'value':'this-is-way-too-long' },
            { 'value':'just-right' }
        ]
    }
".Replace("'", "\"");

            var cfg = new TestLength(json);

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

            var problems = cfg.Errors();

            Assert.AreEqual(2, problems.Length);
            Assert.IsTrue(problems[0] == "The value too-short is too short. It is 9 characters. It must be at least 10 characters.");
            Assert.IsTrue(problems[1] == "The value this-is-way-too-long is too long. It is 20 characters. It must not exceed 15 characters.");
        }