diff --git a/tests/ImageSharp.Tests/TestBase.cs b/tests/ImageSharp.Tests/TestBase.cs
index 8a83746e7b..175bf215c4 100644
--- a/tests/ImageSharp.Tests/TestBase.cs
+++ b/tests/ImageSharp.Tests/TestBase.cs
@@ -7,25 +7,11 @@ namespace ImageSharp.Tests
{
using System.IO;
- using ImageSharp.Formats;
-
///
/// The test base class. Inherit from this class for any image manipulation tests.
///
public abstract class TestBase
{
- ///
- /// Initializes static members of the class.
- ///
- static TestBase()
- {
- // Register the individual image formats.
- Bootstrapper.Default.AddImageFormat(new PngFormat());
- Bootstrapper.Default.AddImageFormat(new JpegFormat());
- Bootstrapper.Default.AddImageFormat(new BmpFormat());
- Bootstrapper.Default.AddImageFormat(new GifFormat());
- }
-
///
/// Creates the image output directory.
///
diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs
index 4237fdb514..65f712f72c 100644
--- a/tests/ImageSharp.Tests/TestFile.cs
+++ b/tests/ImageSharp.Tests/TestFile.cs
@@ -2,31 +2,56 @@
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
//
+
namespace ImageSharp.Tests
{
- using System;
using System.Collections.Concurrent;
using System.IO;
+ using ImageSharp.Formats;
+
+ ///
+ /// A test image file.
+ ///
public class TestFile
{
- private static readonly ConcurrentDictionary cache = new ConcurrentDictionary();
- private static readonly string FormatsDirectory = GetFormatsDirectory();
+ ///
+ /// The test file cache.
+ ///
+ private static readonly ConcurrentDictionary Cache = new ConcurrentDictionary();
- private static string GetFormatsDirectory()
- {
- // Here for code coverage tests.
- string directory = "TestImages/Formats/";
- if (Directory.Exists(directory))
- {
- return directory;
- }
- return "../../../../TestImages/Formats/";
- }
+ ///
+ /// The formats directory.
+ ///
+ private static readonly string FormatsDirectory = GetFormatsDirectory();
+ ///
+ /// The image.
+ ///
private readonly Image image;
+
+ ///
+ /// The file.
+ ///
private readonly string file;
+ ///
+ /// Initializes static members of the class.
+ ///
+ static TestFile()
+ {
+ // Register the individual image formats.
+ // TODO: Is this the best place to do this?
+ Bootstrapper.Default.AddImageFormat(new PngFormat());
+ Bootstrapper.Default.AddImageFormat(new JpegFormat());
+ Bootstrapper.Default.AddImageFormat(new BmpFormat());
+ Bootstrapper.Default.AddImageFormat(new GifFormat());
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The file.
private TestFile(string file)
{
this.file = file;
@@ -35,50 +60,98 @@ namespace ImageSharp.Tests
this.image = new Image(this.Bytes);
}
- public static string GetPath(string file)
- {
- return Path.Combine(FormatsDirectory, file);
- }
+ ///
+ /// Gets the bytes.
+ ///
+ public byte[] Bytes { get; }
- public static TestFile Create(string file)
- {
- return cache.GetOrAdd(file, (string fileName) =>
- {
- return new TestFile(GetPath(file));
- });
- }
+ ///
+ /// The file name.
+ ///
+ public string FileName => Path.GetFileName(this.file);
- public byte[] Bytes { get; }
+ ///
+ /// The file name without extension.
+ ///
+ public string FileNameWithoutExtension => Path.GetFileNameWithoutExtension(this.file);
- public string FileName
+ ///
+ /// Gets the full qualified path to the file.
+ ///
+ ///
+ /// The file path.
+ ///
+ ///
+ /// The .
+ ///
+ public static string GetPath(string file)
{
- get
- {
- return Path.GetFileName(this.file);
- }
+ return Path.Combine(FormatsDirectory, file);
}
- public string FileNameWithoutExtension
+ ///
+ /// Creates a new test file or returns one from the cache.
+ ///
+ /// The file path.
+ ///
+ /// The .
+ ///
+ public static TestFile Create(string file)
{
- get
- {
- return Path.GetFileNameWithoutExtension(this.file);
- }
+ return Cache.GetOrAdd(file, (string fileName) => new TestFile(GetPath(file)));
}
+ ///
+ /// Gets the file name.
+ ///
+ /// The value.
+ ///
+ /// The .
+ ///
public string GetFileName(object value)
{
- return this.FileNameWithoutExtension + "-" + value + Path.GetExtension(this.file);
+ return $"{this.FileNameWithoutExtension}-{value}{Path.GetExtension(this.file)}";
}
+ ///
+ /// Gets the file name without extension.
+ ///
+ /// The value.
+ ///
+ /// The .
+ ///
public string GetFileNameWithoutExtension(object value)
{
return this.FileNameWithoutExtension + "-" + value;
}
+ ///
+ /// Creates a new image.
+ ///
+ ///
+ /// The .
+ ///
public Image CreateImage()
{
return new Image(this.image);
}
+
+ ///
+ /// Gets the correct path to the formats directory.
+ ///
+ ///
+ /// The .
+ ///
+ private static string GetFormatsDirectory()
+ {
+ // Here for code coverage tests.
+ string directory = "TestImages/Formats/";
+ if (Directory.Exists(directory))
+ {
+ return directory;
+ }
+
+ return "../../../../TestImages/Formats/";
+ }
}
}