Created
January 22, 2018 08:15
-
-
Save hermanussen/570c556e02ab7cbc7ca854ddb23072e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
[Description("Tests the import of an image into the media library")] | |
public void TestImageImport() | |
{ | |
string sampleImage = ConfigurationManager.AppSettings["sampleimage"]; | |
SampleSitecoreLogic.ImportImage(sampleImage); | |
// Get the imported media item | |
MediaItem imported = new MediaItem(Sitecore.Context.Database.GetItem("/sitecore/media library/Cdm")); | |
Assert.IsNotNull(imported, "Imported image could not be found"); | |
Assert.AreEqual("Image", imported.InnerItem.TemplateName); | |
// Get the imported image data and put it in a memory stream | |
MemoryStream memoryStream = new MemoryStream(); | |
imported.GetMediaStream().CopyTo(memoryStream); | |
Assert.IsTrue( | |
Sitecore.IO.FileUtil.ReadBinaryFile(sampleImage).SequenceEqual(memoryStream.ToArray()), | |
"The imported image's content is different from the file"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment