diff --git a/src/SixLabors.Core/Helpers/Guard.cs b/src/SixLabors.Core/Helpers/Guard.cs
index 0e4ef336d4..b50cd4ab04 100644
--- a/src/SixLabors.Core/Helpers/Guard.cs
+++ b/src/SixLabors.Core/Helpers/Guard.cs
@@ -14,60 +14,6 @@ namespace SixLabors
[DebuggerStepThrough]
internal static class Guard
{
- ///
- /// Verifies, that the method parameter with specified object value is not null
- /// and throws an exception if it is found to be so.
- ///
- /// The target object, which cannot be null.
- /// The name of the parameter that is to be checked.
- /// is null
- /// The type of the object to verify
- public static void NotNull(T target, string parameterName)
- where T : class
- {
- if (target is null)
- {
- throw new ArgumentNullException(parameterName);
- }
- }
-
- ///
- /// Verifies, that the string method parameter with specified object value and message
- /// is not null, not empty and does not contain only blanks and throws an exception
- /// if the object is null.
- ///
- /// The target string, which should be checked against being null or empty.
- /// Name of the parameter.
- /// is null.
- /// is empty or contains only blanks.
- public static void NotNullOrEmpty(string target, string parameterName)
- {
- NotNull(target, parameterName);
-
- if (string.IsNullOrWhiteSpace(target))
- {
- throw new ArgumentException("Value cannot be null, empty, or cannot contain only whitespace.", parameterName);
- }
- }
-
- ///
- /// Verifies, that the enumeration is not null and not empty.
- ///
- /// The type of objects in the
- /// The target enumeration, which should be checked against being null or empty.
- /// Name of the parameter.
- /// is null.
- /// is empty.
- public static void NotNullOrEmpty(IEnumerable target, string parameterName)
- {
- NotNull(target, parameterName);
-
- if (!target.Any())
- {
- throw new ArgumentException("Value cannot be empty.", parameterName);
- }
- }
-
///
/// Verifies that the specified value is less than a maximum value
/// and throws an exception if it is not.
@@ -80,7 +26,7 @@ namespace SixLabors
/// is greater than the maximum value.
///
public static void MustBeLessThan(TValue value, TValue max, string parameterName)
- where TValue : IComparable
+ where TValue : IComparable
{
if (value.CompareTo(max) >= 0)
{
@@ -100,7 +46,7 @@ namespace SixLabors
/// is greater than the maximum value.
///
public static void MustBeLessThanOrEqualTo(TValue value, TValue max, string parameterName)
- where TValue : IComparable
+ where TValue : IComparable
{
if (value.CompareTo(max) > 0)
{
diff --git a/tests/SixLabors.Core.Tests/Helpers/GuardTests.cs b/tests/SixLabors.Core.Tests/Helpers/GuardTests.cs
index fee12db175..f95e46e355 100644
--- a/tests/SixLabors.Core.Tests/Helpers/GuardTests.cs
+++ b/tests/SixLabors.Core.Tests/Helpers/GuardTests.cs
@@ -2,91 +2,12 @@
// Licensed under the Apache License, Version 2.0.
using System;
-using System.Collections.Generic;
using Xunit;
namespace SixLabors.Helpers.Tests
{
public class GuardTests
{
- [Fact]
- public void NotNull_TargetNotNull_ThrowsNoException()
- {
- Guard.NotNull("test", "myParamName");
- }
-
- [Fact]
- public void NotNull_TargetNull_ThrowsException()
- {
- Assert.Throws(() =>
- {
- Guard.NotNull((object)null, "myParamName");
- });
- }
-
- [Fact]
- public void NotNullOrEmpty_TargetNotNullOrEmpty_ThrowsNoException()
- {
- Guard.NotNullOrEmpty("test", "myParamName");
- }
-
- [Fact]
- public void NotNullOrEmpty_TargetNull_ThrowsException()
- {
- Assert.Throws(() =>
- {
- Guard.NotNullOrEmpty(null, "myParamName");
- });
- }
-
- [Fact]
- public void NotNullOrEmpty_TargetWhitespace_ThrowsException()
- {
- Assert.Throws(() =>
- {
- Guard.NotNullOrEmpty("\n\n", "myParamName");
- });
- }
-
- [Fact]
- public void NotNullOrEmpty_TargetEmpty_ThrowsException()
- {
- var exception = Assert.Throws(() =>
- {
- Guard.NotNullOrEmpty(string.Empty, "myParamName");
- });
-
- Assert.Equal("myParamName", exception.ParamName);
- Assert.True(exception.Message.Contains("Value cannot be null, empty, or cannot contain only whitespace."));
- }
-
- [Fact]
- public void NotNullOrEmptyIEnumerable_TargetNotNullOrEmpty_ThrowsNoException()
- {
- Guard.NotNullOrEmpty(new string[] { "test" }, "myParamName");
- }
-
- [Fact]
- public void NotNullOrEmptyIEnumerable_TargetNull_ThrowsException()
- {
- Assert.Throws(() =>
- {
- Guard.NotNullOrEmpty((IEnumerable)null, "myParamName");
- });
- }
-
- [Fact]
- public void NotNullOrEmptyIEnumerable_TargetEmpty_ThrowsException()
- {
- var exception = Assert.Throws(() =>
- {
- Guard.NotNullOrEmpty(new string[] { }, "myParamName");
- });
-
- Assert.Equal("myParamName", exception.ParamName);
- Assert.True(exception.Message.Contains("Value cannot be empty."));
- }
-
[Fact]
public void MustBeLessThan_IsLess_ThrowsNoException()
{