From 0c5539c46b188937dcfab01a1ef9897be860fc56 Mon Sep 17 00:00:00 2001 From: Florian Levis Date: Fri, 3 May 2024 15:34:16 +0200 Subject: [PATCH] tests: update tests following code review --- .../Statistics/MomentsTests/TheGetChannelMethod.cs | 2 +- .../Statistics/PerceptualHashTests/TheGetChannelMethod.cs | 2 +- .../PerceptualHashTests/TheSumSquaredDistanceMethod.cs | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/Magick.NET.Tests/Statistics/MomentsTests/TheGetChannelMethod.cs b/tests/Magick.NET.Tests/Statistics/MomentsTests/TheGetChannelMethod.cs index 34d45be891..5cbf51c2a0 100644 --- a/tests/Magick.NET.Tests/Statistics/MomentsTests/TheGetChannelMethod.cs +++ b/tests/Magick.NET.Tests/Statistics/MomentsTests/TheGetChannelMethod.cs @@ -11,7 +11,7 @@ public partial class MomentsTests public class TheGetChannelMethod { [Fact] - public void ShouldThrowExceptionWhenChannelDoesNotExist() + public void ShouldReturnNullWhenChannelDoesNotExist() { using var image = new MagickImage(Files.ImageMagickJPG); var moments = image.Moments(); diff --git a/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheGetChannelMethod.cs b/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheGetChannelMethod.cs index 0ec1f1cb6a..5f66459ddc 100644 --- a/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheGetChannelMethod.cs +++ b/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheGetChannelMethod.cs @@ -11,7 +11,7 @@ public partial class PerceptualHashTests public class TheGetChannelMethod { [Fact] - public void ShouldThrowExceptionWhenChannelDoesNotExist() + public void ShouldReturnNullWhenChannelDoesNotExist() { var hash = new PerceptualHash("81b4488652898d48a7a9622346206e620f8a646682939835e986ec98c78f887ae8c67f81b1e884c58a0d18af2d622718fd35623ffdeac9a78cbaedaa81d888434e824c683ad781c37895978c8688c426628ed61b216279b81b48887318a1628af43622a2619d162372"); diff --git a/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheSumSquaredDistanceMethod.cs b/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheSumSquaredDistanceMethod.cs index 377e359365..003a1d6c12 100644 --- a/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheSumSquaredDistanceMethod.cs +++ b/tests/Magick.NET.Tests/Statistics/PerceptualHashTests/TheSumSquaredDistanceMethod.cs @@ -12,9 +12,7 @@ public partial class PerceptualHashTests public class TestPerceptualHash : IPerceptualHash { public IChannelPerceptualHash GetChannel(PixelChannel channel) - { - return null; - } + => null; public double SumSquaredDistance(IPerceptualHash other) { @@ -29,8 +27,10 @@ public void ShouldThrowNotSupportedExceptionIfCustomImplementationDoesNotHaveExp { using var image = new MagickImage(Files.ImageMagickJPG); var phash = image.PerceptualHash(); + Assert.NotNull(phash); - Assert.Throws(() => phash.SumSquaredDistance(new TestPerceptualHash())); + var exception = Assert.Throws(() => phash.SumSquaredDistance(new TestPerceptualHash())); + Assert.Equal("other IPerceptualHash must have Red, Green and Blue channel", exception.Message); } [Fact]