-
Notifications
You must be signed in to change notification settings - Fork 390
Expand file tree
/
Copy pathTest_Guard.Array.cs
More file actions
146 lines (122 loc) · 5.27 KB
/
Test_Guard.Array.cs
File metadata and controls
146 lines (122 loc) · 5.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CommunityToolkit.Diagnostics.UnitTests;
public partial class Test_Guard
{
[TestMethod]
public void Test_Guard_IsEmpty_ArrayOk()
{
Guard.IsEmpty(new int[0], nameof(Test_Guard_IsEmpty_ArrayOk));
}
[TestMethod]
public void Test_Guard_IsEmpty_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.IsEmpty(new int[1], nameof(Test_Guard_IsEmpty_ArrayFail)));
}
[TestMethod]
public void Test_Guard_IsNotEmpty_ArrayOk()
{
Guard.IsNotEmpty(new int[1], nameof(Test_Guard_IsNotEmpty_ArrayOk));
}
[TestMethod]
public void Test_Guard_IsNotEmpty_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.IsNotEmpty(new int[0], nameof(Test_Guard_IsNotEmpty_ArrayFail)));
}
[TestMethod]
public void Test_Guard_HasSizeEqualTo_ArrayOk()
{
Guard.HasSizeEqualTo(new int[4], 4, nameof(Test_Guard_HasSizeEqualTo_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeEqualTo_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeEqualTo(new int[3], 4, nameof(Test_Guard_HasSizeEqualTo_ArrayOk)));
}
[TestMethod]
public void Test_Guard_HasSizeNotEqualTo_ArrayOk()
{
Guard.HasSizeNotEqualTo(new int[3], 4, nameof(Test_Guard_HasSizeNotEqualTo_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeNotEqualTo_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeNotEqualTo(new int[4], 4, nameof(Test_Guard_HasSizeNotEqualTo_ArrayFail)));
}
[TestMethod]
public void Test_Guard_HasSizeGreaterThan_ArrayOk()
{
Guard.HasSizeGreaterThan(new int[5], 2, nameof(Test_Guard_HasSizeGreaterThan_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeGreaterThan_ArrayEqualFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeGreaterThan(new int[4], 4, nameof(Test_Guard_HasSizeGreaterThan_ArrayEqualFail)));
}
[TestMethod]
public void Test_Guard_HasSizeGreaterThan_ArraySmallerFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThan_ArraySmallerFail)));
}
[TestMethod]
public void Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayOk()
{
Guard.HasSizeGreaterThanOrEqualTo(new int[5], 2, nameof(Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayOk));
Guard.HasSizeGreaterThanOrEqualTo(new int[2], 2, nameof(Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeGreaterThan(new int[1], 4, nameof(Test_Guard_HasSizeGreaterThanOrEqualTo_ArrayFail)));
}
[TestMethod]
public void Test_Guard_HasSizeLessThan_ArrayOk()
{
Guard.HasSizeLessThan(new int[1], 5, nameof(Test_Guard_HasSizeLessThan_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeLessThan_ArrayEqualFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeLessThan(new int[4], 4, nameof(Test_Guard_HasSizeLessThan_ArrayEqualFail)));
}
[TestMethod]
public void Test_Guard_HasSizeLessThan_ArrayGreaterFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeLessThan(new int[6], 4, nameof(Test_Guard_HasSizeLessThan_ArrayGreaterFail)));
}
[TestMethod]
public void Test_Guard_HasSizeLessThanOrEqualTo_ArrayOk()
{
Guard.HasSizeLessThanOrEqualTo(new int[1], 5, nameof(Test_Guard_HasSizeLessThanOrEqualTo_ArrayOk));
Guard.HasSizeLessThanOrEqualTo(new int[5], 5, nameof(Test_Guard_HasSizeLessThanOrEqualTo_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeLessThanOrEqualTo_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeLessThanOrEqualTo(new int[8], 4, nameof(Test_Guard_HasSizeLessThanOrEqualTo_ArrayFail)));
}
[TestMethod]
public void Test_Guard_HasSizeEqualToArray_ArrayOk()
{
Guard.HasSizeEqualTo(new int[1], new int[1], nameof(Test_Guard_HasSizeEqualToArray_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeEqualToArray_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeEqualToArray_ArrayFail)));
}
[TestMethod]
public void Test_Guard_HasSizeLessThanOrEqualToArray_ArrayOk()
{
Guard.HasSizeLessThanOrEqualTo(new int[2], new int[5], nameof(Test_Guard_HasSizeLessThanOrEqualToArray_ArrayOk));
Guard.HasSizeLessThanOrEqualTo(new int[4], new int[4], nameof(Test_Guard_HasSizeLessThanOrEqualToArray_ArrayOk));
}
[TestMethod]
public void Test_Guard_HasSizeLessThanOrEqualToArray_ArrayFail()
{
_ = Assert.ThrowsExactly<ArgumentException>(() => Guard.HasSizeLessThanOrEqualTo(new int[8], new int[2], nameof(Test_Guard_HasSizeLessThanOrEqualToArray_ArrayFail)));
}
}