-
-
Notifications
You must be signed in to change notification settings - Fork 868
/
Copy pathBlankProvider.cs
52 lines (41 loc) · 1.55 KB
/
BlankProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// 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);
}
}
}