// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) James South.
// Licensed under the Apache License, Version 2.0.
//
//
// Unit tests for the ImageFactory (loading of images)
//
// --------------------------------------------------------------------------------------------------------------------
namespace ImageProcessor.UnitTests
{
using System;
using System.IO;
using NUnit.Framework;
///
/// Test harness for the image factory
///
[TestFixture]
public class ImageFactoryUnitTests
{
///
/// The path to the binary's folder
///
private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
///
/// Tests the loading of image from a file
///
[Test]
[TestCase("Chrysanthemum.jpg", "image/jpeg")]
[TestCase("Desert.jpg", "image/jpeg")]
[TestCase("cmyk.png", "image/png")]
[TestCase("Penguins.bmp", "image/bmp")]
[TestCase("Penguins.gif", "image/gif")]
public void TestLoadImageFromFile(string fileName, string expectedMime)
{
var testPhoto = Path.Combine(this.localPath, string.Format("Images/{0}", fileName));
using (ImageFactory imageFactory = new ImageFactory())
{
imageFactory.Load(testPhoto);
Assert.AreEqual(testPhoto, imageFactory.ImagePath);
Assert.AreEqual(expectedMime, imageFactory.MimeType);
Assert.IsNotNull(imageFactory.Image);
}
}
}
}