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.
52 lines
1.5 KiB
52 lines
1.5 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Six Labors Split License.
|
|
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
|
|
using Xunit.Abstractions;
|
|
|
|
namespace SixLabors.ImageSharp.Tests;
|
|
|
|
public abstract partial class TestImageProvider<TPixel> : IXunitSerializable
|
|
where TPixel : unmanaged, IPixel<TPixel>
|
|
{
|
|
private class BlankProvider : TestImageProvider<TPixel>, IXunitSerializable
|
|
{
|
|
public BlankProvider(int width, int height)
|
|
{
|
|
this.Width = width;
|
|
this.Height = height;
|
|
}
|
|
|
|
/// <summary>
|
|
/// This parameterless constructor is needed for xUnit deserialization
|
|
/// </summary>
|
|
public BlankProvider()
|
|
{
|
|
this.Width = 100;
|
|
this.Height = 100;
|
|
}
|
|
|
|
public override string SourceFileOrDescription => TestUtils.AsInvariantString($"Blank{this.Width}x{this.Height}");
|
|
|
|
protected int Height { get; private set; }
|
|
|
|
protected int Width { get; private set; }
|
|
|
|
public override Image<TPixel> GetImage() => new Image<TPixel>(this.Configuration, this.Width, this.Height);
|
|
|
|
public override void Deserialize(IXunitSerializationInfo info)
|
|
{
|
|
this.Width = info.GetValue<int>("width");
|
|
this.Height = info.GetValue<int>("height");
|
|
base.Deserialize(info);
|
|
}
|
|
|
|
public override void Serialize(IXunitSerializationInfo info)
|
|
{
|
|
info.AddValue("width", this.Width);
|
|
info.AddValue("height", this.Height);
|
|
base.Serialize(info);
|
|
}
|
|
}
|
|
}
|
|
|