示例#1
0
 public void DateTimeSetTest([PexAssumeUnderTest] XmpTag target, DateTime?value)
 {
     PexAssume.IsNotNull(value);
     target.DateTime = value;
     PexAssert.AreEqual(value.ToString(), target.GetTextNode(XmpTag.XAP_NS, "CreateDate").ToString());
     // TODO: add assertions to method XmpTagTest.DateTimeSetTest(XmpTag, Nullable`1<DateTime>)
 }
示例#2
0
        public string ModelGetTest([PexAssumeUnderTest] XmpTag target, string value)
        {
            target.Model = value;
            string result = target.Model;

            PexAssert.AreEqual(result, target.GetTextNode(XmpTag.TIFF_NS, "Model"));
            return(result);
            // TODO: add assertions to method XmpTagTest.ModelGetTest(XmpTag)
        }
示例#3
0
        /// <summary>
        /// Load the properties of the specified MetaData object from the specified ImageTag.
        /// tagMain may be a CombinedImageTag (when working with a real image file) or an XmpTag (when working with an XMP file).
        /// Most of the data is read simply from the XmpTag (which is the Xmp property of the combined tag, if it is not tagMain itself).
        /// But, we don't want to pass combinedTag.Xmp when working with a file, because some files may have CopyRightNotice or Creator
        /// stored (only) in some other tag;
        /// and we need to handle the case where we only have an XmpTag, because there appears to be no way to create a
        /// combinedTag that just has an XmpTag inside it (or indeed any way to create any combinedTag except as part of
        /// reading a real image file).
        /// </summary>
        private static void LoadProperties(ImageTag tagMain, Metadata m)
        {
            m.CopyrightNotice = tagMain.Copyright;
            m.Creator         = tagMain.Creator;
            XmpTag xmpTag = tagMain as XmpTag;

            if (xmpTag == null)
            {
                xmpTag = ((CombinedImageTag)tagMain).Xmp;
            }
            var licenseProperties = new Dictionary <string, string>();

            if (xmpTag != null)
            {
                m.CollectionUri = xmpTag.GetTextNode(kNsCollections,
                                                     "CollectionURI");
                m.CollectionName = xmpTag.GetTextNode(
                    kNsCollections,
                    "CollectionName");
                m.AttributionUrl = xmpTag.GetTextNode(kNsCc, "attributionURL");

                var licenseUrl = xmpTag.GetTextNode(kNsCc, "license");
                if (!string.IsNullOrWhiteSpace(licenseUrl))
                {
                    licenseProperties["license"] = licenseUrl;
                }
                var rights = GetRights(xmpTag);
                if (rights != null)
                {
                    licenseProperties["rights (en)"] = rights;
                }
            }
            m.License = LicenseInfo.FromXmp(licenseProperties);

            //NB: we're loosing non-ascii somewhere... the copyright symbol is just the most obvious
            if (!string.IsNullOrEmpty(m.CopyrightNotice))
            {
                m.CopyrightNotice = m.CopyrightNotice.Replace("Copyright �", "Copyright ©");
            }

            //clear out the change-setting we just caused, because as of right now, we are clean with respect to what is on disk, no need to save.
            m.HasChanges = false;
        }
示例#4
0
        public DateTime?DateTimeGetTest([PexAssumeUnderTest] XmpTag target, DateTime datetime)
        {
            PexAssume.IsNotNull(datetime);
            target.DateTime = datetime;
            DateTime?result = target.DateTime;

            PexAssert.AreEqual(result.ToString(), target.GetTextNode(XmpTag.XAP_NS, "CreateDate").ToString());
            return(result);
            // TODO: add assertions to method XmpTagTest.DateTimeGetTest(XmpTag)
        }
示例#5
0
 public void ReplaceFromTest([PexAssumeUnderTest] XmpTag target, XmpTag tag, string ns, string name, string value)
 {
     PexAssume.IsNotNull(tag);
     PexAssume.IsNotNull(ns);
     PexAssume.IsNotNull(name);
     PexAssume.IsNotNull(value);
     tag.SetTextNode(ns, name, value);
     target.ReplaceFrom(tag);
     PexAssert.AreEqual(value, target.GetTextNode(ns, name));
     // TODO: add assertions to method XmpTagTest.ReplaceFromTest(XmpTag, XmpTag)
 }
示例#6
0
 public void SetTextNodeTest(
     [PexAssumeUnderTest] XmpTag target,
     string ns,
     string name,
     string value
     )
 {
     PexAssume.IsNotNull(ns);
     PexAssume.IsNotNull(name);
     target.SetTextNode(ns, name, value);
     PexAssert.AreEqual(target.GetTextNode(ns, name), value);
     // TODO: add assertions to method XmpTagTest.SetTextNodeTest(XmpTag, String, String, String)
 }
示例#7
0
        public string GetTextNodeTest(
            [PexAssumeUnderTest] XmpTag target,
            string ns,
            string name,
            string value
            )
        {
            PexAssume.IsNotNull(ns);
            PexAssume.IsNotNull(name);
            PexAssume.IsNotNull(value);
            target.SetTextNode(ns, name, value);
            string result = target.GetTextNode(ns, name);

            PexAssert.AreEqual(result, value);
            return(result);
            // TODO: add assertions to method XmpTagTest.GetTextNodeTest(XmpTag, String, String)
        }
示例#8
0
 public void SoftwareSetTest([PexAssumeUnderTest] XmpTag target, string value)
 {
     target.Software = value;
     PexAssert.AreEqual(value, target.GetTextNode(XmpTag.XAP_NS, "CreatorTool"));
     // TODO: add assertions to method XmpTagTest.SoftwareSetTest(XmpTag, String)
 }
示例#9
0
 public string SoftwareGetTest([PexAssumeUnderTest] XmpTag target)
 {
     PexAssert.AreEqual(target.Software, target.GetTextNode(XmpTag.XAP_NS, "CreatorTool"));
     return(target.Software);
     // TODO: add assertions to method XmpTagTest.SoftwareGetTest(XmpTag)
 }
示例#10
0
 public void ModelSetTest([PexAssumeUnderTest] XmpTag target, string value)
 {
     target.Model = value;
     PexAssert.AreEqual(value, target.GetTextNode(XmpTag.TIFF_NS, "Model"));
     // TODO: add assertions to method XmpTagTest.ModelSetTest(XmpTag, String)
 }