forked from sarbian/ModuleManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagTest.cs
More file actions
145 lines (117 loc) · 3.74 KB
/
Copy pathTagTest.cs
File metadata and controls
145 lines (117 loc) · 3.74 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
using System;
using Xunit;
using ModuleManager.Tags;
namespace ModuleManagerTests.Tags
{
public class TagTest
{
[Fact]
public void Test__OnlyKey()
{
Tag tag = new Tag("key", null, null);
Assert.Equal("key", tag.key);
Assert.Null(tag.value);
Assert.Null(tag.trailer);
}
[Fact]
public void Test__KeyAndValue()
{
Tag tag = new Tag("key", "value", null);
Assert.Equal("key", tag.key);
Assert.Equal("value", tag.value);
Assert.Null(tag.trailer);
}
[Fact]
public void Test__KeyAndEmptyValue()
{
Tag tag = new Tag("key", "", null);
Assert.Equal("key", tag.key);
Assert.Equal("", tag.value);
Assert.Null(tag.trailer);
}
[Fact]
public void Test__KeyValueAndTrailer()
{
Tag tag = new Tag("key", "value", "trailer");
Assert.Equal("key", tag.key);
Assert.Equal("value", tag.value);
Assert.Equal("trailer", tag.trailer);
}
[Fact]
public void Test__KeyEmptyValueAndTrailer()
{
Tag tag = new Tag("key", "", "trailer");
Assert.Equal("key", tag.key);
Assert.Equal("", tag.value);
Assert.Equal("trailer", tag.trailer);
}
[Fact]
public void TestConstructor__KeyNull()
{
ArgumentNullException ex = Assert.Throws<ArgumentNullException>(delegate
{
new Tag(null, "value", "trailer");
});
Assert.Equal("key", ex.ParamName);
}
[Fact]
public void TestConstructor__KeyEmpty()
{
ArgumentException ex = Assert.Throws<ArgumentException>(delegate
{
new Tag("", "value", "trailer");
});
Assert.Equal("key", ex.ParamName);
Assert.Contains("can't be empty", ex.Message);
}
[Fact]
public void TestConstructor__ValueNullButTrailerNotNull()
{
ArgumentException ex = Assert.Throws<ArgumentException>(delegate
{
new Tag("key", null, "trailer");
});
Assert.Contains("trailer must be null if value is null", ex.Message);
}
[Fact]
public void TestConstructor__TrailerEmpty()
{
ArgumentException ex = Assert.Throws<ArgumentException>(delegate
{
new Tag("key", "value", "");
});
Assert.Equal("trailer", ex.ParamName);
Assert.Contains("can't be empty (null allowed)", ex.Message);
}
[Fact]
public void TestToString__Key()
{
Tag tag = new Tag("key", null, null);
Assert.Equal("< 'key' >", tag.ToString());
}
[Fact]
public void TestToString__KeyAndValue()
{
Tag tag = new Tag("key", "value", null);
Assert.Equal("< 'key' [ 'value' ] >", tag.ToString());
}
[Fact]
public void TestToString__KeyAndEmptyValue()
{
Tag tag = new Tag("key", "", null);
Assert.Equal("< 'key' [ '' ] >", tag.ToString());
}
[Fact]
public void TestToString__KeyValueAndTrailer()
{
Tag tag = new Tag("key", "value", "trailer");
Assert.Equal("< 'key' [ 'value' ] 'trailer' >", tag.ToString());
}
[Fact]
public void TestToString__KeyEmptyValueAndTrailer()
{
Tag tag = new Tag("key", "", "trailer");
Assert.Equal("< 'key' [ '' ] 'trailer' >", tag.ToString());
}
}
}