public void ImageIsLoadedFromFile()
        {
            foreach (FileInfo file in ImageSources.GetInputImageFiles())
            {
                using (ImageFactory imageFactory = new ImageFactory())
                {
                    imageFactory.Load(file.FullName);

                    imageFactory.ImagePath.Should().Be(file.FullName, "because the path should have been memorized");
                    imageFactory.Image.Should().NotBeNull("because the image should have been loaded");
                }
            }
        }
        public void ImageIsLoadedFromByteArray()
        {
            foreach (FileInfo file in ImageSources.GetInputImageFiles())
            {
                byte[] photoBytes = File.ReadAllBytes(file.FullName);

                using (ImageFactory imageFactory = new ImageFactory())
                {
                    imageFactory.Load(photoBytes);

                    imageFactory.ImagePath.Should().BeNull("because an image loaded from byte array should not have a file path");
                    imageFactory.Image.Should().NotBeNull("because the image should have been loaded");
                }
            }
        }
 public void BackgroundColorIsChanged()
 {
     using (ImageFactory imageFactory = new ImageFactory())
     {
         imageFactory.Load(ImageSources.GetFilePathByName("text.png"));
         using (Image original = imageFactory.Image.Copy())
         {
             imageFactory.BackgroundColor(Color.Yellow);
             AssertionHelpers.AssertImagesAreDifferent(
                 original,
                 imageFactory.Image,
                 "because the background color operation should have been applied on {0}",
                 imageFactory.ImagePath);
         }
     }
 }
        /// <summary>
        /// Lists the input images to use from the Images folder
        /// </summary>
        /// <returns>The list of images</returns>
        private IEnumerable <ImageFactory> ListInputImages(params string[] extensions)
        {
            foreach (ImageFactory image in this.imagesFactories)
            {
                image.Dispose();
            }

            this.imagesFactories.Clear();

            foreach (FileInfo fi in ImageSources.GetInputImageFiles(extensions))
            {
                this.imagesFactories.Add((new ImageFactory()).Load(fi.FullName));
            }

            return(this.imagesFactories);
        }
        public void ImageIsSavedToDisk()
        {
            foreach (FileInfo file in ImageSources.GetInputImageFiles())
            {
                string outputFileName = string.Format("{0}{1}", OutputPath, file.Name);
                using (ImageFactory imageFactory = new ImageFactory())
                {
                    imageFactory.Load(file.FullName);
                    imageFactory.Save(outputFileName);

                    File.Exists(outputFileName).Should().BeTrue("because the file should have been saved on disk");

                    File.Delete(outputFileName);
                }
            }
        }
        /// <summary>
        /// Lists the input images to use from the Images folder
        /// </summary>
        /// <returns>The list of images</returns>
        private IEnumerable <ImageFactory> ListInputImagesWithMetadata(params string[] extensions)
        {
            if (this.imagesFactories == null || !this.imagesFactories.Any())
            {
                this.imagesFactories = new List <ImageFactory>();
                foreach (FileInfo fi in ImageSources.GetInputImageFiles(extensions))
                {
                    this.imagesFactories.Add((new ImageFactory(true)).Load(fi.FullName));
                }
            }

            // reset all the images whenever we call this
            foreach (ImageFactory image in this.imagesFactories)
            {
                image.Reset();
            }

            return(this.imagesFactories);
        }