Exemplo n.º 1
0
        public void Test_FromXDocument()
        {
            using (MagickImage image = new MagickImage(Files.InvitationTif))
            {
                XmpProfile profile = image.GetXmpProfile();
                Assert.IsNotNull(profile);

                XDocument doc = profile.ToXDocument();

                ExceptionAssert.Throws <ArgumentNullException>(delegate()
                {
                    XmpProfile.FromXDocument(null);
                });

                XmpProfile newProfile = XmpProfile.FromXDocument(doc);
                image.AddProfile(newProfile);

                doc = profile.ToXDocument();
                TestXDocument(doc);

                profile = image.GetXmpProfile();
                Assert.IsNotNull(profile);

                doc = profile.ToXDocument();
                TestXDocument(doc);

                Assert.AreEqual(profile, newProfile);
            }
        }
Exemplo n.º 2
0
        public void Test_FromXDocument()
        {
            using (var image = new MagickImage(Files.InvitationTIF))
            {
                var profile = image.GetXmpProfile();
                Assert.NotNull(profile);

                var doc = profile.ToXDocument();

                Assert.Throws <ArgumentNullException>("document", () =>
                {
                    XmpProfile.FromXDocument(null);
                });

                var newProfile = XmpProfile.FromXDocument(doc);
                image.SetProfile(newProfile);

                doc = profile.ToXDocument();
                TestXDocument(doc);

                profile = image.GetXmpProfile();
                Assert.NotNull(profile);

                doc = profile.ToXDocument();
                TestXDocument(doc);

                Assert.Equal(profile, newProfile);
            }
        }
 public void ShouldThrowExceptionWhenDocumentIsNull()
 {
     Assert.Throws <ArgumentNullException>("document", () =>
     {
         XmpProfile.FromXDocument(null);
     });
 }
            public void ShouldCreateProfileFromIXDocument()
            {
                var document = XDocument.Parse("<test />");

                var profile = XmpProfile.FromXDocument(document);

                Assert.NotNull(profile);
                Assert.Equal(@"<?xml version=""1.0"" encoding=""utf-8""?><test />", Encoding.UTF8.GetString(profile.ToByteArray()));
            }