Beispiel #1
0
        public T GetInterpreter <T>() where T : class, IInterpreter
        {
            IInterpreter v = null;

            if (typeof(T) == typeof(RegularExpressionInterpreter))
            {
                v = new RegularExpressionInterpreter();
            }
            if (typeof(T) == typeof(InvalidChildElementInterpreter))
            {
                v = new InvalidChildElementInterpreter();
            }
            if (v == null)
            {
                throw new ArgumentException("The supplied validator type '" + typeof(T).FullName + "' could not be loaded");
            }
            if (null != this.Logs)
            {
                foreach (var l in this.Logs)
                {
                    v.Logs.Add(l);
                }
            }
            if (null != this.TimedLogs)
            {
                foreach (var l in this.TimedLogs)
                {
                    v.TimedLogs.Add(l);
                }
            }
            return(v as T);
        }
 public void Invalid_IncorrectElementNamespace()
 {
     var interpreter = new XCRI.Validation.XmlExceptionInterpretation.InvalidChildElementInterpreter();
     System.Xml.Linq.XElement furtherInformation;
     string updatedMessage = String.Empty;
     string standardMessage = @"The element 'provider' in namespace 'http://xcri.org/profiles/1.2/catalog' has invalid child element 'description' in namespace 'http://xcri.org/profiles/1.2/catalog'. List of possible elements expected: 'hasPart' in namespace 'http://purl.org/net/mlo' as well as 'contributor' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'contributor' in namespace 'http://purl.org/dc/terms/' as well as 'date' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'date, created, valid, available, issued, modified, dateAccepted, dateCopyrighted, dateSubmitted' in namespace 'http://purl.org/dc/terms/' as well as 'description' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'description, tableOfContents, abstract' in namespace 'http://purl.org/dc/terms/' as well as 'identifier' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'identifier, bibliographicCitation' in namespace 'http://purl.org/dc/terms/' as well as 'image' in namespace 'http://xcri.org/profiles/1.2/catalog' as well as 'subject' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'subject' in namespace 'http://purl.org/dc/terms/' as well as 'title' in namespace 'http://purl.org/dc/elements/1.1/'.";
     Assert.AreEqual<InterpretationStatus>
         (
         InterpretationStatus.Interpreted,
         interpreter.Interpret(new Exception(standardMessage), out furtherInformation, ref updatedMessage)
         );
     Assert.AreNotEqual<string>(standardMessage, updatedMessage, "The message returned was not interpreted.");
     Assert.AreEqual<string>("The element 'description' should be in namespace 'http://purl.org/dc/elements/1.1/', not 'http://xcri.org/profiles/1.2/catalog'.", updatedMessage, "The message returned was unexpected.");
 }
Beispiel #3
0
        public void Invalid_IncorrectElementNamespace()
        {
            var interpreter = new XCRI.Validation.XmlExceptionInterpretation.InvalidChildElementInterpreter();

            System.Xml.Linq.XElement furtherInformation;
            string updatedMessage  = String.Empty;
            string standardMessage = @"The element 'provider' in namespace 'http://xcri.org/profiles/1.2/catalog' has invalid child element 'description' in namespace 'http://xcri.org/profiles/1.2/catalog'. List of possible elements expected: 'hasPart' in namespace 'http://purl.org/net/mlo' as well as 'contributor' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'contributor' in namespace 'http://purl.org/dc/terms/' as well as 'date' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'date, created, valid, available, issued, modified, dateAccepted, dateCopyrighted, dateSubmitted' in namespace 'http://purl.org/dc/terms/' as well as 'description' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'description, tableOfContents, abstract' in namespace 'http://purl.org/dc/terms/' as well as 'identifier' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'identifier, bibliographicCitation' in namespace 'http://purl.org/dc/terms/' as well as 'image' in namespace 'http://xcri.org/profiles/1.2/catalog' as well as 'subject' in namespace 'http://purl.org/dc/elements/1.1/' as well as 'subject' in namespace 'http://purl.org/dc/terms/' as well as 'title' in namespace 'http://purl.org/dc/elements/1.1/'.";

            Assert.AreEqual <InterpretationStatus>
            (
                InterpretationStatus.Interpreted,
                interpreter.Interpret(new Exception(standardMessage), out furtherInformation, ref updatedMessage)
            );
            Assert.AreNotEqual <string>(standardMessage, updatedMessage, "The message returned was not interpreted.");
            Assert.AreEqual <string>("The element 'description' should be in namespace 'http://purl.org/dc/elements/1.1/', not 'http://xcri.org/profiles/1.2/catalog'.", updatedMessage, "The message returned was unexpected.");
        }