|  | 
| 1 | 1 | [TestFixture] | 
| 2 | 2 | public class GuardTests | 
| 3 | 3 | { | 
| 4 |  | -    string nullString = null!; | 
| 5 |  | -    List<string> nullList = null!; | 
| 6 |  | -    IList<string> nullIList = null!; | 
| 7 |  | -    IReadOnlyList<string> nullIReadOnlyList = null!; | 
| 8 |  | -    ICollection<string> nullICollection = null!; | 
| 9 |  | -    IReadOnlyCollection<string> nullIReadOnlyCollection = null!; | 
| 10 |  | -    IEnumerable<string> nullEnumerable = null!; | 
| 11 |  | -    string[] nullArray = null!; | 
| 12 |  | -    Dictionary<int, string> nullDictionary = null!; | 
| 13 |  | -    IDictionary<int, string> nullIDictionary = null!; | 
| 14 |  | -    IReadOnlyDictionary<int, string> nullIReadOnlyDictionary = null!; | 
| 15 |  | -    object nullObject = null!; | 
|  | 4 | +    static  string nullString = null!; | 
|  | 5 | + static   List<string> nullList = null!; | 
|  | 6 | + static   IList<string> nullIList = null!; | 
|  | 7 | + static   IReadOnlyList<string> nullIReadOnlyList = null!; | 
|  | 8 | + static   ICollection<string> nullICollection = null!; | 
|  | 9 | + static   IReadOnlyCollection<string> nullIReadOnlyCollection = null!; | 
|  | 10 | + static   IEnumerable<string> nullEnumerable = null!; | 
|  | 11 | + static   string[] nullArray = null!; | 
|  | 12 | + static   Dictionary<int, string> nullDictionary = null!; | 
|  | 13 | + static   IDictionary<int, string> nullIDictionary = null!; | 
|  | 14 | + static   IReadOnlyDictionary<int, string> nullIReadOnlyDictionary = null!; | 
|  | 15 | + static   object nullObject = null!; | 
| 16 | 16 | 
 | 
| 17 |  | -    string emptyString = string.Empty; | 
| 18 |  | -    List<string> emptyList = []; | 
| 19 |  | -    IList<string> emptyIList = []; | 
| 20 |  | -    IReadOnlyList<string> emptyIReadOnlyList = []; | 
| 21 |  | -    ICollection<string> emptyICollection = []; | 
| 22 |  | -    IReadOnlyCollection<string> emptyIReadOnlyCollection = []; | 
| 23 |  | -    IEnumerable<string> emptyEnumerable = []; | 
| 24 |  | -    Dictionary<int, string> emptyDictionary = new(); | 
| 25 |  | -    IDictionary<int, string> emptyIDictionary = new Dictionary<int, string>(); | 
| 26 |  | -    IReadOnlyDictionary<int, string> emptyIReadOnlyDictionary = new Dictionary<int, string>(); | 
| 27 |  | -    string[] emptyArray = []; | 
|  | 17 | + static   string emptyString = string.Empty; | 
|  | 18 | +    static   List<string> emptyList = []; | 
|  | 19 | + static IList<string> emptyIList = []; | 
|  | 20 | + static IReadOnlyList<string> emptyIReadOnlyList = []; | 
|  | 21 | + static ICollection<string> emptyICollection = []; | 
|  | 22 | + static IReadOnlyCollection<string> emptyIReadOnlyCollection = []; | 
|  | 23 | + static IEnumerable<string> emptyEnumerable = []; | 
|  | 24 | + static Dictionary<int, string> emptyDictionary = new(); | 
|  | 25 | + static IDictionary<int, string> emptyIDictionary = new Dictionary<int, string>(); | 
|  | 26 | + static IReadOnlyDictionary<int, string> emptyIReadOnlyDictionary = new Dictionary<int, string>(); | 
|  | 27 | + static string[] emptyArray = []; | 
|  | 28 | + static string[] nonEmptyArray = ["value"]; | 
|  | 29 | + static List<string> nonEmptyList = ["value"]; | 
|  | 30 | + static IEnumerable<string> nonEmptyEnumerable = nonEmptyList.Select(x => x); | 
| 28 | 31 | 
 | 
| 29 | 32 |     [Test] | 
| 30 | 33 |     public void NotNull() | 
| @@ -53,6 +56,10 @@ public void NotNull() | 
| 53 | 56 |             () => Guard.NotNull(nullIDictionary)); | 
| 54 | 57 |         Assert.Throws<ArgumentNullException>( | 
| 55 | 58 |             () => Guard.NotNull(nullIReadOnlyDictionary)); | 
|  | 59 | +        Guard.NotNull(nonEmptyArray); | 
|  | 60 | +        Guard.NotNull(nonEmptyEnumerable); | 
|  | 61 | +        Guard.NotNull("value"); | 
|  | 62 | +        Guard.NotNull(nonEmptyEnumerable); | 
| 56 | 63 |     } | 
| 57 | 64 | 
 | 
| 58 | 65 |     [Test] | 
| @@ -112,6 +119,10 @@ public void NotNullOrEmpty() | 
| 112 | 119 |             () => Guard.NotNullOrEmpty(nullIDictionary)); | 
| 113 | 120 |         Assert.Throws<ArgumentNullException>( | 
| 114 | 121 |             () => Guard.NotNullOrEmpty(nullIReadOnlyDictionary)); | 
|  | 122 | +        Guard.NotNullOrEmpty(nonEmptyArray); | 
|  | 123 | +        Guard.NotNullOrEmpty(nonEmptyEnumerable); | 
|  | 124 | +        Guard.NotNullOrEmpty("value"); | 
|  | 125 | +        Guard.NotNullOrEmpty(nonEmptyEnumerable); | 
| 115 | 126 |     } | 
| 116 | 127 | 
 | 
| 117 | 128 |     [Test] | 
| @@ -166,6 +177,9 @@ public void NotEmpty() | 
| 166 | 177 |         Guard.NotEmpty(nullIReadOnlyList); | 
| 167 | 178 |         Guard.NotEmpty(nullIReadOnlyCollection); | 
| 168 | 179 |         Guard.NotEmpty(nullArray); | 
|  | 180 | +        Guard.NotEmpty(nonEmptyArray); | 
|  | 181 | +        Guard.NotEmpty("value"); | 
|  | 182 | +        Guard.NotEmpty(nonEmptyList); | 
| 169 | 183 |         Guard.NotEmpty(nullEnumerable); | 
| 170 | 184 |         Guard.NotEmpty(nullDictionary); | 
| 171 | 185 |         Guard.NotEmpty(nullIDictionary); | 
|  | 
0 commit comments