Пример #1
0
        public void XAttributeThrowExceptionValidate()
        {
            String elementName    = "note";
            String attributeName  = "date";
            object attributeValue = "2010-12-32";

            // validate the entire document
            validationSucceded = true;
            ExtensionsClass.Validate(xmlDocument, schemaSet,
                                     new ValidationEventHandler(TestValidationHandler), true);
            Assert.AreEqual(true, validationSucceded);

            // change and re-validate attribute value
            XAttribute date = xmlDocument.Element(elementName).Attribute(attributeName);

            date.SetValue(attributeValue);
            ExtensionsClass.Validate(date, date.GetSchemaInfo().SchemaAttribute, schemaSet, null);
        }
Пример #2
0
        public void XAttributeSuccessValidate()
        {
            string elementName = "note";
            string attributeName = "date";
            object attributeValue = "2010-05-27";

            // validate the entire document
            validationSucceeded = true;
            ExtensionsClass.Validate(xmlDocument, schemaSet,
                new ValidationEventHandler(TestValidationHandler), true);
            Assert.True(validationSucceeded);

            // change and re-validate attribute value
            XAttribute date = xmlDocument.Element(elementName).Attribute(attributeName);
            date.SetValue(attributeValue);
            ExtensionsClass.Validate(date, date.GetSchemaInfo().SchemaAttribute,schemaSet,
                new ValidationEventHandler(TestValidationHandler));
            Assert.True(validationSucceeded);
        }
Пример #3
0
        public void XAttributeGetSchemaInfo()
        {
            string elementName =  "note";
            string attributeName = "date";

            // validate the entire document
            validationSucceeded = true;
            ExtensionsClass.Validate(xmlDocument, schemaSet,
                new ValidationEventHandler(TestValidationHandler), true);
            Assert.True(validationSucceeded);

            // validate attribute
            XAttribute date = xmlDocument.Element(elementName).Attribute(attributeName);
            ExtensionsClass.Validate(date, date.GetSchemaInfo().SchemaAttribute, schemaSet,
                new ValidationEventHandler(TestValidationHandler));
            Assert.True(validationSucceeded);

            IXmlSchemaInfo schemaInfo =  ExtensionsClass.GetSchemaInfo(date);
            Assert.NotNull(schemaInfo);
        }