/// <exception cref="Platform.Xml.Sax.SAXException"></exception> private void AssertValidHl7Message(string xml) { XmlDocument document = new DocumentFactory().CreateFromString(xml); MessageValidatorResult result = new MessageValidatorImpl(new MockTestCaseMessageDefinitionService()).Validate(document, MockVersionNumber .MOCK_MR2009); foreach (Hl7Error error in result.GetHl7Errors()) { Assert.Fail(error.ToString()); } }
public static void Validate(string xmlString, VersionNumber versionNumber) { try { Console.WriteLine("\nValidation Errors: "); XmlDocument document = new DocumentFactory().CreateFromString(xmlString); MessageValidatorImpl validator = CreateNewValidator(); MessageValidatorResult result = validator.Validate(document, versionNumber); Console.WriteLine("There are {0} errors\n", result.GetHl7Errors().Count); foreach (Hl7Error hl7Err in result.GetHl7Errors()) { Console.WriteLine("Error ({0}): {1} at XPath: {2}\n", hl7Err.GetHl7ErrorCode(), hl7Err.GetMessage(), hl7Err.GetPath()); } } catch (Exception e) { // XML parsing error Console.WriteLine(e.StackTrace); } }
public MessageValidatorTests() { this.validator = new MessageValidatorImpl(); }