Beispiel #1
0
        public string CommentGetDescriptionTest([PexAssumeUnderTest] XmpTag target, string value)
        {
            PexAssume.IsNotNull(value);
            target.SetLangAltNode(XmpTag.DC_NS, "description", value);
            string result = target.Comment;

            PexAssert.AreEqual(result, target.GetLangAltNode(XmpTag.DC_NS, "description"));
            return(result);
            // TODO: add assertions to method XmpTagTest.CommentGetTest(XmpTag)
        }
Beispiel #2
0
 public void SetLangAltNodeTest(
     [PexAssumeUnderTest] XmpTag target,
     string ns,
     string name,
     string value
     )
 {
     PexAssume.IsNotNull(ns);
     PexAssume.IsNotNull(name);
     target.SetLangAltNode(ns, name, value);
     PexAssert.AreEqual(target.GetLangAltNode(ns, name), value);
     // TODO: add assertions to method XmpTagTest.SetLangAltNodeTest(XmpTag, String, String, String)
 }
Beispiel #3
0
        void SetRights(XmpTag xmp, string rights)
        {
            var rightsNode = xmp.FindNode("http://purl.org/dc/elements/1.1/", "rights");

            if (rightsNode == null)
            {
                if (string.IsNullOrEmpty(rights))
                {
                    return;                     // leave it missing.
                }
                // No existing rights node, and we have some. We use (default lang) rights for copyright too, and there seems to be no way to
                // make the base node without setting that. So set it to something meaningless.
                // This will typically never happen, since our dialog requires a non-empty copyright.
                // I'm not entirely happy with it, but as far as I can discover the current version of taglib cannot
                // set the 'en' alternative of dc:rights without setting the  default alternative. In fact, I'm not sure the
                // result of doing so would technically be valid xmp; the standard calls for every langauge alternation
                // to have a default.
                xmp.SetLangAltNode("http://purl.org/dc/elements/1.1/", "rights", "Unknown");
                rightsNode = xmp.FindNode("http://purl.org/dc/elements/1.1/", "rights");
            }
            foreach (var child in rightsNode.Children)
            {
                if (child.Namespace == "http://www.w3.org/1999/02/22-rdf-syntax-ns#" && child.Name == "li" &&
                    HasLangQualifier(child, "en"))
                {
                    if (string.IsNullOrEmpty(rights))
                    {
                        rightsNode.RemoveChild(child);
                        // enhance: possibly we should remove rightsNode, if it now has no children, and if taglib can.
                        // However, we always require a copyright, so this will typically not happen.
                    }
                    else
                    {
                        child.Value = rights;
                    }
                    return;
                }
            }
            // Didn't find an existing rights:en node.
            if (string.IsNullOrEmpty(rights))
            {
                return;                 // leave it missing.
            }
            var childNode = new XmpNode(XmpTag.RDF_NS, "li", rights);

            childNode.AddQualifier(new XmpNode(XmpTag.XML_NS, "lang", "en"));

            rightsNode.AddChild(childNode);
        }