diff --git a/src/ImageProcessorCore/Common/Helpers/Guard.cs b/src/ImageProcessorCore/Common/Helpers/Guard.cs
index c5efb01ea..1e9b3ea23 100644
--- a/src/ImageProcessorCore/Common/Helpers/Guard.cs
+++ b/src/ImageProcessorCore/Common/Helpers/Guard.cs
@@ -174,18 +174,13 @@ namespace ImageProcessorCore
/// The error message, if any to add to the exception.
///
///
- /// is null
+ /// is false
///
- public static void IsTrue(bool target, string parameterName, string message = "")
+ public static void IsTrue(bool target, string parameterName, string message)
{
if (!target)
{
- if (!string.IsNullOrWhiteSpace(message))
- {
- throw new ArgumentException(parameterName, message);
- }
-
- throw new ArgumentException(parameterName);
+ throw new ArgumentException(message, parameterName);
}
}
@@ -197,18 +192,13 @@ namespace ImageProcessorCore
/// The name of the parameter that is to be checked.
/// The error message, if any to add to the exception.
///
- /// is null
+ /// is true
///
- public static void IsFalse(bool target, string parameterName, string message = "")
+ public static void IsFalse(bool target, string parameterName, string message)
{
if (target)
{
- if (!string.IsNullOrWhiteSpace(message))
- {
- throw new ArgumentException(parameterName, message);
- }
-
- throw new ArgumentException(parameterName);
+ throw new ArgumentException(message, parameterName);
}
}
}
diff --git a/tests/ImageProcessorCore.Tests/Helpers/GuardTests.cs b/tests/ImageProcessorCore.Tests/Helpers/GuardTests.cs
index 7c33470c3..b92c4e0a8 100644
--- a/tests/ImageProcessorCore.Tests/Helpers/GuardTests.cs
+++ b/tests/ImageProcessorCore.Tests/Helpers/GuardTests.cs
@@ -207,7 +207,7 @@ namespace ImageProcessorCore.Tests.Helpers
[Fact]
public void IsTrueThrowsWhenArgIsFalse()
{
- Assert.Throws(() => Guard.IsTrue(false, "foo"));
+ Assert.Throws(() => Guard.IsTrue(false, "foo", "message"));
}
///
@@ -216,7 +216,7 @@ namespace ImageProcessorCore.Tests.Helpers
[Fact]
public void IsTrueDoesThrowsWhenArgIsTrue()
{
- Exception ex = Record.Exception(() => Guard.IsTrue(true, "foo"));
+ Exception ex = Record.Exception(() => Guard.IsTrue(true, "foo", "message"));
Assert.Null(ex);
}
@@ -226,7 +226,7 @@ namespace ImageProcessorCore.Tests.Helpers
[Fact]
public void IsFalseThrowsWhenArgIsFalse()
{
- Assert.Throws(() => Guard.IsFalse(true, "foo"));
+ Assert.Throws(() => Guard.IsFalse(true, "foo", "message"));
}
///
@@ -235,7 +235,7 @@ namespace ImageProcessorCore.Tests.Helpers
[Fact]
public void IsFalseDoesThrowsWhenArgIsTrue()
{
- Exception ex = Record.Exception(() => Guard.IsFalse(false, "foo"));
+ Exception ex = Record.Exception(() => Guard.IsFalse(false, "foo", "message"));
Assert.Null(ex);
}
}