mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.8 KiB
49 lines
1.8 KiB
// --------------------------------------------------------------------------------------------------------------------
|
|
// <copyright file="ImageFactoryUnitTests.cs" company="James South">
|
|
// Copyright (c) James South.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
// <summary>
|
|
// Unit tests for the ImageFactory (loading of images)
|
|
// </summary>
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
namespace ImageProcessor.UnitTests
|
|
{
|
|
using System;
|
|
using System.IO;
|
|
using NUnit.Framework;
|
|
|
|
/// <summary>
|
|
/// Test harness for the image factory
|
|
/// </summary>
|
|
[TestFixture]
|
|
public class ImageFactoryUnitTests
|
|
{
|
|
/// <summary>
|
|
/// The path to the binary's folder
|
|
/// </summary>
|
|
private readonly string localPath = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
|
|
|
|
/// <summary>
|
|
/// Tests the loading of image from a file
|
|
/// </summary>
|
|
[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);
|
|
}
|
|
}
|
|
}
|
|
}
|