Browse Source

[SL.Core] Remove unused Gaurd.IsTrue and Gaurd.IsFalse

af/octree-no-pixelmap
Jason Nelson 8 years ago
parent
commit
929007d9a4
  1. 42
      src/SixLabors.Core/Helpers/Guard.cs
  2. 36
      tests/SixLabors.Core.Tests/Helpers/GuardTests.cs

42
src/SixLabors.Core/Helpers/Guard.cs

@ -169,48 +169,6 @@ namespace SixLabors
}
}
/// <summary>
/// Verifies, that the method parameter with specified target value is true
/// and throws an exception if it is found to be so.
/// </summary>
/// <param name="value">
/// The target value, which cannot be false.
/// </param>
/// <param name="parameterName">
/// The name of the parameter that is to be checked.
/// </param>
/// <param name="message">
/// The error message, if any to add to the exception.
/// </param>
/// <exception cref="ArgumentException">
/// <paramref name="value"/> is false
/// </exception>
public static void IsTrue(bool value, string parameterName, string message)
{
if (!value)
{
throw new ArgumentException(message, parameterName);
}
}
/// <summary>
/// Verifies, that the method parameter with specified target value is false
/// and throws an exception if it is found to be so.
/// </summary>
/// <param name="value">The target value, which cannot be true.</param>
/// <param name="parameterName">The name of the parameter that is to be checked.</param>
/// <param name="message">The error message, if any to add to the exception.</param>
/// <exception cref="ArgumentException">
/// <paramref name="value"/> is true
/// </exception>
public static void IsFalse(bool value, string parameterName, string message)
{
if (value)
{
throw new ArgumentException(message, parameterName);
}
}
/// <summary>
/// Verifies, that the `target` span has the length of 'minLength', or longer.
/// </summary>

36
tests/SixLabors.Core.Tests/Helpers/GuardTests.cs

@ -190,42 +190,6 @@ namespace SixLabors.Helpers.Tests
Assert.True(exception.Message.Contains($"Value must be greater than or equal to {min} and less than or equal to {max}."));
}
[Fact]
public void IsTrue_IsTrue_ThrowsNoException()
{
Guard.IsTrue(true, "myParamName", "myTestMessage");
}
[Fact]
public void IsTrue_IsFalse_ThrowsException()
{
var exception = Assert.Throws<ArgumentException>(() =>
{
Guard.IsTrue(false, "myParamName", "myTestMessage");
});
Assert.Equal("myParamName", exception.ParamName);
Assert.True(exception.Message.Contains("myTestMessage"));
}
[Fact]
public void IsFalse_IsFalse_ThrowsNoException()
{
Guard.IsFalse(false, "myParamName", "myTestMessage");
}
[Fact]
public void IsFalse_IsTrue_ThrowsException()
{
var exception = Assert.Throws<ArgumentException>(() =>
{
Guard.IsFalse(true, "myParamName", "myTestMessage");
});
Assert.Equal("myParamName", exception.ParamName);
Assert.True(exception.Message.Contains("myTestMessage"));
}
[Theory]
[InlineData(2, 1)]
[InlineData(2, 2)]

Loading…
Cancel
Save