Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;NU1608;NU1109</NoWarn>
<Version>3.6.0</Version>
<Version>3.7.0</Version>
<AssemblyVersion>1.0.0</AssemblyVersion>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
Expand Down
4 changes: 2 additions & 2 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="Polyfill" Version="7.27.0" />
<PackageVersion Include="ProjectDefaults" Version="1.0.150" />
<PackageVersion Include="Verify" Version="29.3.1" />
<PackageVersion Include="Verify" Version="29.4.0" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.Nunit" Version="29.3.1" />
<PackageVersion Include="Verify.Nunit" Version="29.4.0" />
</ItemGroup>
</Project>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Tests/Tests.VerifyPdf#00.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Tests/Tests.VerifyPdf#01.verified.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ public Task CompareSame()
return Verify(compare);
}

[Test]
public Task ShouldNotMessWithTargetName() =>
Verify(new Target("png", File.OpenRead("sample.jpg"), "name"));

[Test]
public Task ShouldNotMessWithTargetNames() =>
Verify(
targets:
[
new("png", File.OpenRead("sample.jpg"), "name1"),
new("png", File.OpenRead("sample.jpg"), "name2")
]);

[Test]
public Task CompareDifferent()
{
Expand All @@ -38,4 +51,12 @@ public Task CompareDifferent()
File.OpenRead("sample.png"));
return Verify(compare);
}

[Test]
public Task VerifyPdf() =>
VerifyFile("sample.pdf");

[Test]
public Task VerifyPdfWithName() =>
Verify(targets: [new("pdf", File.OpenRead("sample.pdf"), "name")]);
}
16 changes: 8 additions & 8 deletions src/Verify.ImageMagick/VerifyImageMagick.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ public static void Initialize()

InnerVerifier.ThrowIfVerifyHasBeenRun();
FileExtensions.RemoveTextExtension("svg");
VerifierSettings.RegisterFileConverter(
VerifierSettings.RegisterStreamConverter(
"svg",
ConvertSvg);
VerifierSettings.RegisterFileConverter(
VerifierSettings.RegisterStreamConverter(
"png",
(stream, context) => ConvertImage(stream, context, "png", MagickFormat.Png));
VerifierSettings.RegisterFileConverter(
(name, stream, context) => ConvertImage(name, stream, context, "png", MagickFormat.Png));
VerifierSettings.RegisterStreamConverter(
"tiff",
(stream, context) => ConvertImage(stream, context, "tiff", MagickFormat.Tiff));
(name, stream, context) => ConvertImage(name, stream, context, "tiff", MagickFormat.Tiff));
RegisterPdfToPngConverter();
}

static ConversionResult ConvertImage(Stream stream, IReadOnlyDictionary<string, object> context, string extension, MagickFormat format)
static ConversionResult ConvertImage(string? name, Stream stream, IReadOnlyDictionary<string, object> context, string extension, MagickFormat format)
{
var background = context.Background();
if (background == null)
{
return new(null, [new(extension, stream)]);
return new(null, [new(extension, stream, name)]);
}

var image = new MagickImage(
Expand All @@ -45,7 +45,7 @@ static ConversionResult ConvertImage(Stream stream, IReadOnlyDictionary<string,
var flattened = Flatten(image, background);
var imageStream = new MemoryStream();
flattened.Write(imageStream);
return new(null, [new(extension, imageStream)]);
return new(null, [new(extension, imageStream, name)]);
}

static IMagickImage<ushort> Flatten(IMagickImage<ushort> image, MagickColor background)
Expand Down
8 changes: 4 additions & 4 deletions src/Verify.ImageMagick/VerifyImageMagick_Pdf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public static partial class VerifyImageMagick
public static void RegisterPdfToPngConverter()
{
InnerVerifier.ThrowIfVerifyHasBeenRun();
VerifierSettings.RegisterFileConverter(
VerifierSettings.RegisterStreamConverter(
"pdf",
(stream, context) => Convert(stream, context, MagickFormat.Pdf));
(name, stream, context) => Convert(name, stream, context, MagickFormat.Pdf));
}

static ConversionResult Convert(Stream stream, IReadOnlyDictionary<string, object> context, MagickFormat magickFormat)
static ConversionResult Convert(string? name, Stream stream, IReadOnlyDictionary<string, object> context, MagickFormat magickFormat)
{
var streams = new List<Stream>();
var magickSettings = context.MagickReadSettings();
Expand Down Expand Up @@ -47,6 +47,6 @@ static ConversionResult Convert(Stream stream, IReadOnlyDictionary<string, objec
streams.Add(memoryStream);
}

return new(null, streams.Select(_ => new Target("png", _)));
return new(null, streams.Select(_ => new Target("png", _, name)));
}
}
6 changes: 3 additions & 3 deletions src/Verify.ImageMagick/VerifyImageMagick_Svg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace VerifyTests;

public static partial class VerifyImageMagick
{
static ConversionResult ConvertSvg(Stream stream, IReadOnlyDictionary<string, object> context)
static ConversionResult ConvertSvg(string? name, Stream stream, IReadOnlyDictionary<string, object> context)
{
stream = WrapStream(stream);
using var svg = ReadSvgStream(stream, context);
Expand All @@ -13,8 +13,8 @@ static ConversionResult ConvertSvg(Stream stream, IReadOnlyDictionary<string, ob
return new(
null,
[
new("svg", stream),
new("png", pngStream)
new("svg", stream, name),
new("png", pngStream, name)
]);
}

Expand Down