@@ -12,207 +12,207 @@ public class InvalidFileCheckerTests : TestBase
12
12
[ SetUp ]
13
13
public void CreateTemporaryProject ( )
14
14
{
15
- projectDirectory = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ;
16
- projectFile = Path . Combine ( projectDirectory , "Fake.csproj" ) ;
15
+ projectDirectory = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ;
16
+ projectFile = Path . Combine ( projectDirectory , "Fake.csproj" ) ;
17
17
18
- Directory . CreateDirectory ( projectDirectory ) ;
18
+ Directory . CreateDirectory ( projectDirectory ) ;
19
19
20
- File . Create ( projectFile ) . Close ( ) ;
20
+ File . Create ( projectFile ) . Close ( ) ;
21
21
}
22
22
23
23
[ TearDown ]
24
24
public void Cleanup ( )
25
25
{
26
- Directory . Delete ( projectDirectory , true ) ;
26
+ Directory . Delete ( projectDirectory , true ) ;
27
27
}
28
28
29
29
[ Test ]
30
30
public void VerifyIgnoreNonAssemblyInfoFile ( )
31
31
{
32
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "SomeOtherFile.cs" ) ) )
32
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "SomeOtherFile.cs" ) ) )
33
33
{
34
- writer . Write ( @"
34
+ writer . Write ( @"
35
35
using System;
36
36
using System.Reflection;
37
37
38
38
[assembly: AssemblyVersion(""1.0.0.0"")]
39
- " ) ;
39
+ " ) ;
40
40
}
41
41
42
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "SomeOtherFile.cs" } , projectFile ) ;
42
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "SomeOtherFile.cs" } , projectFile ) ;
43
43
}
44
44
45
45
[ Test ]
46
- public void VerifyAttributeFoundCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System.Reflection.AssemblyVersion" ) ] string attribute )
46
+ public void VerifyAttributeFoundCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System.Reflection.AssemblyVersion" ) ] string attribute )
47
47
{
48
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
48
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
49
49
{
50
- writer . Write ( @"
50
+ writer . Write ( @"
51
51
using System;
52
52
using System.Reflection;
53
53
54
54
[assembly:{0}(""1.0.0.0"")]
55
- " , attribute ) ;
55
+ " , attribute ) ;
56
56
}
57
57
58
- var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) , attribute ) ;
59
- Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs" ) ) ;
58
+ var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) , attribute ) ;
59
+ Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs" ) ) ;
60
60
}
61
61
62
62
[ Test ]
63
- public void VerifyUnformattedAttributeFoundCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System . Reflection . AssemblyVersion" ) ] string attribute )
63
+ public void VerifyUnformattedAttributeFoundCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System . Reflection . AssemblyVersion" ) ] string attribute )
64
64
{
65
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
65
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
66
66
{
67
- writer . Write ( @"
67
+ writer . Write ( @"
68
68
using System;
69
69
using System.Reflection;
70
70
71
71
[ assembly :
72
72
{0} ( ""1.0.0.0"")]
73
- " , attribute ) ;
73
+ " , attribute ) ;
74
74
}
75
75
76
- var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) , attribute ) ;
77
- Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs" ) ) ;
76
+ var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) , attribute ) ;
77
+ Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.cs" ) ) ;
78
78
}
79
79
80
80
[ Test ]
81
- public void VerifyCommentWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
81
+ public void VerifyCommentWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
82
82
{
83
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
83
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
84
84
{
85
- writer . Write ( @"
85
+ writer . Write ( @"
86
86
using System;
87
87
using System.Reflection;
88
88
89
89
//[assembly: {0}(""1.0.0.0"")]
90
- " , attribute ) ;
90
+ " , attribute ) ;
91
91
}
92
92
93
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
93
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
94
94
}
95
95
96
96
[ Test ]
97
- public void VerifyStringWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
97
+ public void VerifyStringWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
98
98
{
99
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
99
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
100
100
{
101
- writer . Write ( @"
101
+ writer . Write ( @"
102
102
using System;
103
103
using System.Reflection;
104
104
105
105
public class Temp
106
106
{{
107
107
static const string Foo = ""[assembly: {0}(""""1.0.0.0"""")]"";
108
108
}}
109
- " , attribute ) ;
109
+ " , attribute ) ;
110
110
}
111
111
112
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
112
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
113
113
}
114
114
115
115
[ Test ]
116
- public void VerifyIdentifierWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
116
+ public void VerifyIdentifierWorksCSharp ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
117
117
{
118
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
118
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.cs" ) ) )
119
119
{
120
- writer . Write ( @"
120
+ writer . Write ( @"
121
121
using System;
122
122
using System.Reflection;
123
123
124
124
public class {0}
125
125
{{
126
126
}}
127
- " , attribute ) ;
127
+ " , attribute ) ;
128
128
}
129
129
130
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
130
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.cs" } , projectFile ) ;
131
131
}
132
132
133
133
[ Test ]
134
- public void VerifyAttributeFoundVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System.Reflection.AssemblyVersion" ) ] string attribute )
134
+ public void VerifyAttributeFoundVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System.Reflection.AssemblyVersion" ) ] string attribute )
135
135
{
136
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
136
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
137
137
{
138
- writer . Write ( @"
138
+ writer . Write ( @"
139
139
Imports System
140
140
Imports System.Reflection
141
141
142
142
<Assembly:{0}(""1.0.0.0"")>
143
- " , attribute ) ;
143
+ " , attribute ) ;
144
144
}
145
145
146
- var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) , attribute ) ;
147
- Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb" ) ) ;
146
+ var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) , attribute ) ;
147
+ Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb" ) ) ;
148
148
}
149
149
150
150
[ Test ]
151
- public void VerifyUnformattedAttributeFoundVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System . Reflection . AssemblyVersion" ) ] string attribute )
151
+ public void VerifyUnformattedAttributeFoundVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" , "System . Reflection . AssemblyVersion" ) ] string attribute )
152
152
{
153
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
153
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
154
154
{
155
- writer . Write ( @"
155
+ writer . Write ( @"
156
156
Imports System
157
157
Imports System.Reflection
158
158
159
159
< Assembly :
160
160
{0} ( ""1.0.0.0"")>
161
- " , attribute ) ;
161
+ " , attribute ) ;
162
162
}
163
163
164
- var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) , attribute ) ;
165
- Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb" ) ) ;
164
+ var ex = Assert . Throws < WarningException > ( ( ) => InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) , attribute ) ;
165
+ Assert . That ( ex . Message , Is . EqualTo ( "File contains assembly version attributes which conflict with the attributes generated by GitVersion AssemblyInfo.vb" ) ) ;
166
166
}
167
167
168
168
[ Test ]
169
- public void VerifyCommentWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
169
+ public void VerifyCommentWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
170
170
{
171
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
171
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
172
172
{
173
- writer . Write ( @"
173
+ writer . Write ( @"
174
174
Imports System
175
175
Imports System.Reflection
176
176
177
177
'<Assembly: {0}(""1.0.0.0"")>
178
- " , attribute ) ;
178
+ " , attribute ) ;
179
179
}
180
180
181
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
181
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
182
182
}
183
183
184
184
[ Test ]
185
- public void VerifyStringWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
185
+ public void VerifyStringWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
186
186
{
187
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
187
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
188
188
{
189
- writer . Write ( @"
189
+ writer . Write ( @"
190
190
Imports System
191
191
Imports System.Reflection
192
192
193
193
Public Class Temp
194
194
static const string Foo = ""<Assembly: {0}(""""1.0.0.0"""")>"";
195
195
End Class
196
- " , attribute ) ;
196
+ " , attribute ) ;
197
197
}
198
198
199
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
199
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
200
200
}
201
201
202
202
[ Test ]
203
- public void VerifyIdentifierWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
203
+ public void VerifyIdentifierWorksVisualBasic ( [ Values ( "AssemblyVersion" , "AssemblyFileVersion" , "AssemblyInformationalVersion" ) ] string attribute )
204
204
{
205
- using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
205
+ using ( var writer = File . CreateText ( Path . Combine ( projectDirectory , "AssemblyInfo.vb" ) ) )
206
206
{
207
- writer . Write ( @"
207
+ writer . Write ( @"
208
208
Imports System
209
209
Imports System.Reflection
210
210
211
211
Public Class {0}
212
212
End Class
213
- " , attribute ) ;
213
+ " , attribute ) ;
214
214
}
215
215
216
- InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
216
+ InvalidFileChecker . CheckForInvalidFiles ( new [ ] { "AssemblyInfo.vb" } , projectFile ) ;
217
217
}
218
218
}
0 commit comments