public void CheckValuednessWithoutValuednessValidationCallback() { using (var reader = XmlReader.Create(new StringReader(XML_CONTENT))) { var navigator = new XPathDocument(reader).CreateNavigator(); var sut = new ValuednessValidator(navigator, null); Invoking(() => sut.Validate()).Should().Throw <XmlException>(); } }
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); sut.Validate().Should().BeFalse(); } }
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); Invoking(() => sut.Validate()) .Should().Throw <XmlException>() .WithMessage( "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")); } }