public void GetXsdValidatorTest() { SerializeTool serialize = new SerializeTool(); var validator = serialize.GetXsdValidator("testobjectToValidate1.xml"); Assert.IsNotNull(validator); if (validator.Validate()) { Debug.Print("OK"); } else { string message = ""; foreach (ValidationErrorInfo validatorLastException in validator.LastExceptions) { message += "\n"; message += $"{validatorLastException.Message} (row/col)=>{validatorLastException.LineNumber}/{validatorLastException.LinePosition}"; } Assert.Fail(message); } }
public void GetXmlValidatorFaialTest() { SerializeTool serialize = new SerializeTool(); var validator = serialize.GetXsdValidator("testobjectToValidate1Fail.xml"); Assert.IsNotNull(validator); if (validator.Validate()) { Assert.Fail("the file must be invalid!"); } else { string message = ""; foreach (ValidationErrorInfo validatorLastException in validator.LastExceptions) { message += "\n"; message += $"{validatorLastException.Message} (row/col)=>{validatorLastException.LineNumber}/{validatorLastException.LinePosition}"; } Assert.IsTrue(message.Length > 0); Assert.IsTrue(message.Contains("Elemente: 'ObjectValue'")); } }