Пример #1
0
 public void CustomValidationEventHandlerTest()
 {
     string xmlFile = XmlFile;
     string schemaFile = XmlSchemaFile;
     XmlValidator target = new XmlValidator(xmlFile, schemaFile);
     object sender = this;
     target.CustomValidationEventHandler(sender, null);
     Assert.IsTrue(target.IsValid());
 }
Пример #2
0
        /// <summary>
        /// Determines whether the given XML file is valid
        /// </summary>
        /// <param name="xmlFile">The XML file.</param>
        /// <param name="schemaFile">The schema file.</param>
        /// <returns>
        ///   <c>true</c> if the supplied XML file is valid; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsValidXml(String xmlFile, String schemaFile)
        {
            bool isValid = false;
            XmlValidator validator = new XmlValidator(xmlFile, schemaFile);

            try
            {
                isValid = validator.IsValid();
            }
            catch (Exception ex)
            {
                throw new ApplicationException(String.Format("Could not validate Xml-File '{0}' against Schema-File '{1}", xmlFile, schemaFile), ex);
            }

            return isValid;
        }
Пример #3
0
 public void XmlValidatorConstructorTest()
 {
     string xmlFile = XmlFile;
     string schemaFile = XmlSchemaFile;
     XmlValidator target = new XmlValidator(xmlFile, schemaFile);
     Assert.IsNotNull(target);
 }
Пример #4
0
 public void IsValidTest()
 {
     string xmlFile = XmlFile;
     string schemaFile = XmlSchemaFile;
     XmlValidator target = new XmlValidator(xmlFile, schemaFile);
     bool expected = true;
     bool actual;
     actual = target.IsValid();
     Assert.AreEqual(expected, actual);
 }