Ejemplo n.º 1
0
        public void Valid_UniqueIdentifiers()
        {
            var xDoc = System.Xml.Linq.XDocument.Parse
                       (
                Resources.ContentValidation.UniqueValidator.Valid.UniqueIdentifiers,
                System.Xml.Linq.LoadOptions.SetLineInfo
                       );

            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
            nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            XCRI.Validation.ContentValidation.UniqueValidator v = new XCRI.Validation.ContentValidation.UniqueValidator()
            {
                XPathSelector    = "//dc:identifier[not(@xsi:type)]",
                NamespaceManager = nsmgr
            };
            var vrc = v.Validate(xDoc.Root);

            Assert.AreEqual <int>(1, vrc.Count());
            var vr = vrc.ElementAt(0);

            Assert.IsNotNull(vr);
            Assert.AreEqual <XCRI.Validation.ContentValidation.ValidationStatus>
            (
                XCRI.Validation.ContentValidation.ValidationStatus.Passed,
                vr.Status
            );

            /*
             * Assert.AreEqual<int>
             *  (
             *  2,
             *  vr.Count
             *  );
             * Assert.AreEqual<int>
             *  (
             *  2,
             *  vr.SuccessCount
             *  );
             */
            Assert.AreEqual <int>
            (
                0,
                vr.FailedCount
            );
            Assert.AreEqual <int>
            (
                0,
                vr.Count
            );
        }
        public void Invalid_NotUniqueIdentifiers()
        {
            var xDoc = System.Xml.Linq.XDocument.Parse
                       (
                Resources.ContentValidation.UniqueValidator.Invalid.NotUnique,
                System.Xml.Linq.LoadOptions.SetLineInfo
                       );

            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
            nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            XCRI.Validation.ContentValidation.UniqueValidator v = new XCRI.Validation.ContentValidation.UniqueValidator()
            {
                XPathSelector    = "//dc:identifier[not(@xsi:type)]",
                NamespaceManager = nsmgr
            };
            var vrc = v.Validate(xDoc.Root);

            Assert.AreEqual <int>(1, vrc.Count());
            var vr = vrc.ElementAt(0);

            Assert.IsNotNull(vr);
            Assert.AreEqual <XCRI.Validation.ContentValidation.ValidationStatus>
            (
                XCRI.Validation.ContentValidation.ValidationStatus.Exception,
                vr.Status
            );
            Assert.AreEqual <int>
            (
                2,
                vr.Count
            );
            Assert.AreEqual <int>
            (
                0,
                vr.SuccessCount
            );
            Assert.AreEqual <int>
            (
                2,
                vr.FailedCount
            );
            Assert.IsTrue(vr.Instances[0].LineNumber.HasValue);
            Assert.IsTrue(vr.Instances[0].LinePosition.HasValue);
            Assert.AreEqual <int>(vr.Instances[0].LineNumber.Value, 11);
            Assert.AreEqual <int>(vr.Instances[0].LinePosition.Value, 8);
            Assert.IsTrue(vr.Instances[1].LineNumber.HasValue);
            Assert.IsTrue(vr.Instances[1].LinePosition.HasValue);
            Assert.AreEqual <int>(vr.Instances[1].LineNumber.Value, 15);
            Assert.AreEqual <int>(vr.Instances[1].LinePosition.Value, 8);
        }
 public void Invalid_NotUniqueIdentifiers()
 {
     var xDoc = System.Xml.Linq.XDocument.Parse
         (
         Resources.ContentValidation.UniqueValidator.Invalid.NotUnique,
         System.Xml.Linq.LoadOptions.SetLineInfo
         );
     System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
     nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
     nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
     XCRI.Validation.ContentValidation.UniqueValidator v = new XCRI.Validation.ContentValidation.UniqueValidator()
     {
         XPathSelector = "//dc:identifier[not(@xsi:type)]",
         NamespaceManager = nsmgr
     };
     var vrc = v.Validate(xDoc.Root);
     Assert.AreEqual<int>(1, vrc.Count());
     var vr = vrc.ElementAt(0);
     Assert.IsNotNull(vr);
     Assert.AreEqual<XCRI.Validation.ContentValidation.ValidationStatus>
         (
         XCRI.Validation.ContentValidation.ValidationStatus.Exception,
         vr.Status
         );
     Assert.AreEqual<int>
         (
         2,
         vr.Count
         );
     Assert.AreEqual<int>
         (
         0,
         vr.SuccessCount
         );
     Assert.AreEqual<int>
         (
         2,
         vr.FailedCount
         );
     Assert.IsTrue(vr.Instances[0].LineNumber.HasValue);
     Assert.IsTrue(vr.Instances[0].LinePosition.HasValue);
     Assert.AreEqual<int>(vr.Instances[0].LineNumber.Value, 11);
     Assert.AreEqual<int>(vr.Instances[0].LinePosition.Value, 8);
     Assert.IsTrue(vr.Instances[1].LineNumber.HasValue);
     Assert.IsTrue(vr.Instances[1].LinePosition.HasValue);
     Assert.AreEqual<int>(vr.Instances[1].LineNumber.Value, 15);
     Assert.AreEqual<int>(vr.Instances[1].LinePosition.Value, 8);
 }
        public void Invalid_MultipleVenuesAtTheSamePresentationWithSameProviderIdentifier()
        {
            var xDoc = System.Xml.Linq.XDocument.Parse
                       (
                Resources.ContentValidation.UniqueValidator.Invalid.MultipleVenuesAtTheSamePresentationWithSameProviderIdentifier,
                System.Xml.Linq.LoadOptions.SetLineInfo
                       );

            System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
            nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
            nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            XCRI.Validation.ContentValidation.UniqueValidator v = new XCRI.Validation.ContentValidation.UniqueValidator()
            {
                XPathSelector    = "//dc:identifier[not(@xsi:type)]",
                NamespaceManager = nsmgr,
                UniqueAcross     = XCRI.Validation.ContentValidation.UniqueValidator.UniqueAcrossTypes.Context
            };
            var vrc = v.Validate(xDoc.Root);

            Assert.AreEqual <int>(1, vrc.Count());
            var vr = vrc.ElementAt(0);

            Assert.IsNotNull(vr);
            Assert.AreEqual <XCRI.Validation.ContentValidation.ValidationStatus>
            (
                XCRI.Validation.ContentValidation.ValidationStatus.Exception,
                vr.Status
            );
            Assert.AreEqual <int>
            (
                3,
                vr.Count
            );
            Assert.AreEqual <int>
            (
                1,
                vr.SuccessCount
            );
            Assert.AreEqual <int>
            (
                2,
                vr.FailedCount
            );
        }
 public void Invalid_MultipleVenuesAtTheSamePresentationWithSameProviderIdentifier()
 {
     var xDoc = System.Xml.Linq.XDocument.Parse
         (
         Resources.ContentValidation.UniqueValidator.Invalid.MultipleVenuesAtTheSamePresentationWithSameProviderIdentifier,
         System.Xml.Linq.LoadOptions.SetLineInfo
         );
     System.Xml.XmlNamespaceManager nsmgr = new System.Xml.XmlNamespaceManager(new System.Xml.NameTable());
     nsmgr.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");
     nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
     XCRI.Validation.ContentValidation.UniqueValidator v = new XCRI.Validation.ContentValidation.UniqueValidator()
     {
         XPathSelector = "//dc:identifier[not(@xsi:type)]",
         NamespaceManager = nsmgr,
         UniqueAcross = XCRI.Validation.ContentValidation.UniqueValidator.UniqueAcrossTypes.Context
     };
     var vrc = v.Validate(xDoc.Root);
     Assert.AreEqual<int>(1, vrc.Count());
     var vr = vrc.ElementAt(0);
     Assert.IsNotNull(vr);
     Assert.AreEqual<XCRI.Validation.ContentValidation.ValidationStatus>
         (
         XCRI.Validation.ContentValidation.ValidationStatus.Exception,
         vr.Status
         );
     Assert.AreEqual<int>
         (
         3,
         vr.Count
         );
     Assert.AreEqual<int>
         (
         1,
         vr.SuccessCount
         );
     Assert.AreEqual<int>
         (
         2,
         vr.FailedCount
         );
 }