-
Notifications
You must be signed in to change notification settings - Fork 2
/
NaturalRange_Test.cs
138 lines (118 loc) · 3.58 KB
/
NaturalRange_Test.cs
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
using System;
using Xunit;
namespace wimm.Secundatives.UnitTests
{
public class NaturalRange_Test
{
private const int _min = 1;
private const int _max = 3;
[Fact]
public void ConstructMax_MaxIsLessThanZero_Throws()
{
var ex = Assert.Throws<ArgumentOutOfRangeException>("max", () => new NaturalRange(-1));
}
[Fact]
public void ConstructMax_ValidArgs_Constructs()
{
var _ = new NaturalRange(_max);
}
[Fact]
public void ConstructMax_MaxIsZero_Constructs()
{
var _ = new NaturalRange(0);
}
[Fact]
public void ConstructMinMax_MinIsLessThanZero_Throws()
{
var ex = Assert.Throws<ArgumentOutOfRangeException>("min", () => new NaturalRange(-1, _max));
}
[Fact]
public void ConstructMinMax_MaxIsLessThanZero_Throws()
{
var ex = Assert.Throws<ArgumentOutOfRangeException>("max", () => new NaturalRange(_min, -1));
}
[Fact]
public void ConstructMinMax_MaxIsLessThanMin_Throws()
{
var ex = Assert.Throws<ArgumentException>(() =>
{
var _ = new NaturalRange(3, 2);
});
}
[Fact]
public void ConstructMinMax_ValidArgs_Constructs()
{
var _ = new NaturalRange(_min, _max);
}
[Fact]
public void ConstructMinMax_MinIsZero_Constructs()
{
var _ = new NaturalRange(0, _max);
}
[Fact]
public void Construct_MaxIsMin_Constructs()
{
var _ = new NaturalRange(_min, _min);
}
[Fact]
public void ConstructMinMax_MaxIsZero_Constructs()
{
// min must also be zero so that max >= min
var _ = new NaturalRange(0, 0);
}
[Fact]
public void Min_ConstructMax_IsZero()
{
var underTest = new NaturalRange(_max);
Assert.Equal(0, underTest.Min);
}
[Fact]
public void Min_ConstructMinMax_IsMin()
{
var underTest = new NaturalRange(_min, _max);
Assert.Equal(_min, underTest.Min);
}
[Fact]
public void Max_ConstrucMax_IsMax()
{
var underTest = new NaturalRange(_max);
Assert.Equal(_max, underTest.Max);
}
[Fact]
public void Max_ConstructMinMax_IsMax()
{
var underTest = new NaturalRange(_min, _max);
Assert.Equal(_max, underTest.Max);
}
[Fact]
public void Includes_ValueIsLessThanMin_False()
{
var underTest = new NaturalRange(_min, _max);
Assert.False(underTest.Includes(_min - 1));
}
[Fact]
public void Includes_ValueIsMin_True()
{
var underTest = new NaturalRange(_min, _max);
Assert.True(underTest.Includes(_min));
}
[Fact]
public void Includes_ValueIsBetweenMinAndMax_True()
{
var underTest = new NaturalRange(_min, _max);
Assert.True(underTest.Includes(_min + 1));
}
[Fact]
public void Includes_ValueIsMax_True()
{
var underTest = new NaturalRange(_min, _max);
Assert.True(underTest.Includes(_max));
}
[Fact]
public void Includes_ValueIsGreaterThanMax_True()
{
var underTest = new NaturalRange(_min, _max);
Assert.False(underTest.Includes(_max + 1));
}
}
}