Пример #1
0
        public void CheckValuednessWithoutValuednessValidationCallback()
        {
            using (var reader = XmlReader.Create(new StringReader(XML_CONTENT)))
            {
                var navigator = new XPathDocument(reader).CreateNavigator();

                var sut = new ValuednessValidator(navigator, null);

                Assert.That(() => sut.Validate(), Throws.TypeOf <XmlException>());
            }
        }
Пример #2
0
        public void CheckValuednessWithValuednessValidationCallbackReportingWarningSeverity()
        {
            ExpectedEmptyNodes = new[] {
                "/*/ns:empty-parent",
                "ns:parent/ns:empty-child",
                "ns:parent/ns:non-nil-child",
                "ns:parent/ns:child/ns:firstname",
                "ns:firstname/@no-language"
            };
            using (var reader = XmlReader.Create(new StringReader(XML_CONTENT)))
            {
                var navigator = new XPathDocument(reader).CreateNavigator();

                var sut = new ValuednessValidator(navigator, ValidationCallback);

                Assert.That(sut.Validate(), Is.False);
            }
        }
Пример #3
0
        public void CheckValuednessWithValuednessValidationCallbackReportingErrorSeverity()
        {
            ExpectedEmptyNodes = new string[] { };
            using (var reader = XmlReader.Create(new StringReader(XML_CONTENT)))
            {
                var navigator = new XPathDocument(reader).CreateNavigator();

                var sut = new ValuednessValidator(navigator, ValidationCallback);

                Assert.That(
                    () => sut.Validate(),
                    Throws.TypeOf <XmlException>()
                    .With.Message.EqualTo(
                        "The following nodes have either no value nor any child element:" + Environment.NewLine + string.Join(
                            Environment.NewLine,
                            "/root/empty-parent",
                            "/root/parent/empty-child[1]",
                            "/root/parent/non-nil-child",
                            "/root/parent/child/firstname",
                            "/root/parent/empty-child[2]",
                            "/root/parent/child/firstname/@no-language")));
            }
        }