-
-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for performing an Fx operation on a MagickImageCollecti…
…on (#1616).
- Loading branch information
Showing
5 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/Magick.NET.Tests/MagickImageCollectionTests/TheFxMethod.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET. | ||
// Licensed under the Apache License, Version 2.0. | ||
|
||
using System; | ||
using ImageMagick; | ||
using Xunit; | ||
|
||
namespace Magick.NET.Tests; | ||
|
||
public partial class MagickImageCollectionTests | ||
{ | ||
public class TheFxMethod | ||
{ | ||
[Fact] | ||
public void ShouldThrowExceptionWhenExpressionIsNull() | ||
{ | ||
using var images = new MagickImageCollection(); | ||
|
||
Assert.Throws<ArgumentNullException>("expression", () => images.Fx(null)); | ||
} | ||
|
||
[Fact] | ||
public void ShouldThrowExceptionWhenExpressionIsEmpty() | ||
{ | ||
using var images = new MagickImageCollection(); | ||
|
||
Assert.Throws<ArgumentException>("expression", () => images.Fx(string.Empty)); | ||
} | ||
|
||
[Fact] | ||
public void ShouldThrowExceptionWhenExpressionIsInvalid() | ||
{ | ||
using var images = new MagickImageCollection | ||
{ | ||
new MagickImage(MagickColors.Purple, 1, 1), | ||
}; | ||
|
||
Assert.Throws<MagickOptionErrorException>(() => images.Fx("foobar")); | ||
} | ||
|
||
[Fact] | ||
public void ShouldEvaluateTheExpression() | ||
{ | ||
using var images = new MagickImageCollection(); | ||
|
||
var logo = new MagickImage(Files.Builtin.Logo); | ||
images.Add(logo); | ||
|
||
var floppedLogo = logo.Clone(); | ||
floppedLogo.Flop(); | ||
images.Add(floppedLogo); | ||
|
||
using var result = images.Fx("(u+v)/2", Channels.Green); | ||
|
||
ColorAssert.Equal(new MagickColor("#ff9fff"), result, 250, 375); | ||
ColorAssert.Equal(new MagickColor("#229f92"), result, 375, 375); | ||
} | ||
} | ||
} |