Skip to content

Commit

Permalink
fix DetectEncoder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antonfirsov committed Nov 25, 2021
1 parent a3a6d1d commit 7ec7447
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions tests/ImageSharp.Tests/Image/ImageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,22 @@ public void KnownExtension_ReturnsEncoder()
}

[Fact]
public void UnknownExtension_ReturnsNull()
public void UnknownExtension_ThrowsNotSupportedException()
{
using var image = new Image<L8>(1, 1);
IImageEncoder encoder = image.DetectEncoder("dummy.yolo");
Assert.Null(encoder);
Assert.Throws<NotSupportedException>(() => image.DetectEncoder("dummy.yolo"));
}

[Fact]
public void NoDetectorRegisteredForKnownExtension_ThrowsNotSupportedException()
{
var configuration = new Configuration();
var format = new TestFormat();
configuration.ImageFormatsManager.AddImageFormat(format);
configuration.ImageFormatsManager.AddImageFormatDetector(new MockImageFormatDetector(format));

using var image = new Image<L8>(configuration, 1, 1);
Assert.Throws<NotSupportedException>(() => image.DetectEncoder($"dummy.{format.Extension}"));
}
}
}
Expand Down

0 comments on commit 7ec7447

Please sign in to comment.