7
7
[ TestFixture ]
8
8
public class ArgumentParserTests
9
9
{
10
-
11
10
[ Test ]
12
11
public void Empty_means_use_current_directory ( )
13
12
{
14
13
var arguments = ArgumentParser . ParseArguments ( "" ) ;
15
- Assert . AreEqual ( Environment . CurrentDirectory , arguments . TargetPath ) ;
16
- Assert . IsNull ( arguments . LogFilePath ) ;
17
- Assert . IsFalse ( arguments . IsHelp ) ;
14
+ arguments . TargetPath . ShouldBe ( Environment . CurrentDirectory ) ;
15
+ arguments . LogFilePath . ShouldBe ( null ) ;
16
+ arguments . IsHelp . ShouldBe ( false ) ;
18
17
}
19
18
20
19
[ Test ]
21
20
public void Single_means_use_as_target_directory ( )
22
21
{
23
22
var arguments = ArgumentParser . ParseArguments ( "path" ) ;
24
- Assert . AreEqual ( "path" , arguments . TargetPath ) ;
25
- Assert . IsNull ( arguments . LogFilePath ) ;
26
- Assert . IsFalse ( arguments . IsHelp ) ;
23
+ arguments . TargetPath . ShouldBe ( "path" ) ;
24
+ arguments . LogFilePath . ShouldBe ( null ) ;
25
+ arguments . IsHelp . ShouldBe ( false ) ;
27
26
}
28
27
29
28
[ Test ]
30
29
public void No_path_and_logfile_should_use_current_directory_TargetDirectory ( )
31
30
{
32
31
var arguments = ArgumentParser . ParseArguments ( "-l logFilePath" ) ;
33
- Assert . AreEqual ( Environment . CurrentDirectory , arguments . TargetPath ) ;
34
- Assert . AreEqual ( "logFilePath" , arguments . LogFilePath ) ;
35
- Assert . IsFalse ( arguments . IsHelp ) ;
32
+ arguments . TargetPath . ShouldBe ( Environment . CurrentDirectory ) ;
33
+ arguments . LogFilePath . ShouldBe ( "logFilePath" ) ;
34
+ arguments . IsHelp . ShouldBe ( false ) ;
36
35
}
37
36
38
37
[ Test ]
@@ -41,14 +40,14 @@ public void h_means_IsHelp()
41
40
var arguments = ArgumentParser . ParseArguments ( "-h" ) ;
42
41
Assert . IsNull ( arguments . TargetPath ) ;
43
42
Assert . IsNull ( arguments . LogFilePath ) ;
44
- Assert . IsTrue ( arguments . IsHelp ) ;
43
+ arguments . IsHelp . ShouldBe ( true ) ;
45
44
}
46
45
47
46
[ Test ]
48
47
public void exec ( )
49
48
{
50
49
var arguments = ArgumentParser . ParseArguments ( "-exec rake" ) ;
51
- Assert . AreEqual ( "rake" , arguments . Exec ) ;
50
+ arguments . Exec . ShouldBe ( "rake" ) ;
52
51
}
53
52
54
53
[ Test ]
@@ -61,15 +60,15 @@ public void exec_with_args()
61
60
"-execargs" ,
62
61
"clean build"
63
62
} ) ;
64
- Assert . AreEqual ( "rake" , arguments . Exec ) ;
65
- Assert . AreEqual ( "clean build" , arguments . ExecArgs ) ;
63
+ arguments . Exec . ShouldBe ( "rake" ) ;
64
+ arguments . ExecArgs . ShouldBe ( "clean build" ) ;
66
65
}
67
66
68
67
[ Test ]
69
68
public void msbuild ( )
70
69
{
71
70
var arguments = ArgumentParser . ParseArguments ( "-proj msbuild.proj" ) ;
72
- Assert . AreEqual ( "msbuild.proj" , arguments . Proj ) ;
71
+ arguments . Proj . ShouldBe ( "msbuild.proj" ) ;
73
72
}
74
73
75
74
[ Test ]
@@ -82,73 +81,80 @@ public void msbuild_with_args()
82
81
"-projargs" ,
83
82
"/p:Configuration=Debug /p:Platform=AnyCPU"
84
83
} ) ;
85
- Assert . AreEqual ( "msbuild.proj" , arguments . Proj ) ;
86
- Assert . AreEqual ( "/p:Configuration=Debug /p:Platform=AnyCPU" , arguments . ProjArgs ) ;
84
+ arguments . Proj . ShouldBe ( "msbuild.proj" ) ;
85
+ arguments . ProjArgs . ShouldBe ( "/p:Configuration=Debug /p:Platform=AnyCPU" ) ;
87
86
}
88
87
89
88
[ Test ]
90
89
public void execwith_targetdirectory ( )
91
90
{
92
91
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -exec rake" ) ;
93
- Assert . AreEqual ( "targetDirectoryPath" , arguments . TargetPath ) ;
94
- Assert . AreEqual ( "rake" , arguments . Exec ) ;
92
+ arguments . TargetPath . ShouldBe ( "targetDirectoryPath" ) ;
93
+ arguments . Exec . ShouldBe ( "rake" ) ;
95
94
}
96
95
97
96
[ Test ]
98
97
public void TargetDirectory_and_LogFilePath_can_be_parsed ( )
99
98
{
100
99
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -l logFilePath" ) ;
101
- Assert . AreEqual ( "targetDirectoryPath" , arguments . TargetPath ) ;
102
- Assert . AreEqual ( "logFilePath" , arguments . LogFilePath ) ;
103
- Assert . IsFalse ( arguments . IsHelp ) ;
100
+ arguments . TargetPath . ShouldBe ( "targetDirectoryPath" ) ;
101
+ arguments . LogFilePath . ShouldBe ( "logFilePath" ) ;
102
+ arguments . IsHelp . ShouldBe ( false ) ;
104
103
}
105
104
106
105
[ Test ]
107
106
public void Username_and_Password_can_be_parsed ( )
108
107
{
109
108
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -u [username] -p [password]" ) ;
110
- Assert . AreEqual ( "targetDirectoryPath" , arguments . TargetPath ) ;
111
- Assert . AreEqual ( "[username]" , arguments . Authentication . Username ) ;
112
- Assert . AreEqual ( "[password]" , arguments . Authentication . Password ) ;
113
- Assert . IsFalse ( arguments . IsHelp ) ;
109
+ arguments . TargetPath . ShouldBe ( "targetDirectoryPath" ) ;
110
+ arguments . Authentication . Username . ShouldBe ( "[username]" ) ;
111
+ arguments . Authentication . Password . ShouldBe ( "[password]" ) ;
112
+ arguments . IsHelp . ShouldBe ( false ) ;
114
113
}
115
114
116
115
[ Test ]
117
116
public void Unknown_output_should_throw ( )
118
117
{
119
118
var exception = Assert . Throws < WarningException > ( ( ) => ArgumentParser . ParseArguments ( "targetDirectoryPath -output invalid_value" ) ) ;
120
- Assert . AreEqual ( "Value 'invalid_value' cannot be parsed as output type, please use 'json' or 'buildserver'" , exception . Message ) ;
119
+ exception . Message . ShouldBe ( "Value 'invalid_value' cannot be parsed as output type, please use 'json' or 'buildserver'" ) ;
121
120
}
122
121
123
122
[ Test ]
124
123
public void Output_defaults_to_json ( )
125
124
{
126
125
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath" ) ;
127
- Assert . AreEqual ( OutputType . Json , arguments . Output ) ;
126
+ arguments . Output . ShouldBe ( OutputType . Json ) ;
128
127
}
129
128
130
129
[ Test ]
131
130
public void Output_json_can_be_parsed ( )
132
131
{
133
132
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -output json" ) ;
134
- Assert . AreEqual ( OutputType . Json , arguments . Output ) ;
133
+ arguments . Output . ShouldBe ( OutputType . Json ) ;
135
134
}
136
135
137
136
[ Test ]
138
137
public void Output_buildserver_can_be_parsed ( )
139
138
{
140
139
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -output buildserver" ) ;
141
- Assert . AreEqual ( OutputType . BuildServer , arguments . Output ) ;
140
+ arguments . Output . ShouldBe ( OutputType . BuildServer ) ;
141
+ }
142
+
143
+ [ Test ]
144
+ public void MultipleArgsAndFlag ( )
145
+ {
146
+ var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -output buildserver -updateAssemblyInfo" ) ;
147
+ arguments . Output . ShouldBe ( OutputType . BuildServer ) ;
142
148
}
143
149
144
150
[ Test ]
145
151
public void Url_and_BranchName_can_be_parsed ( )
146
152
{
147
153
var arguments = ArgumentParser . ParseArguments ( "targetDirectoryPath -url http://github.com/Particular/GitVersion.git -b somebranch" ) ;
148
- Assert . AreEqual ( "targetDirectoryPath" , arguments . TargetPath ) ;
149
- Assert . AreEqual ( "http://github.com/Particular/GitVersion.git" , arguments . TargetUrl ) ;
150
- Assert . AreEqual ( "somebranch" , arguments . TargetBranch ) ;
151
- Assert . IsFalse ( arguments . IsHelp ) ;
154
+ arguments . TargetPath . ShouldBe ( "targetDirectoryPath" ) ;
155
+ arguments . TargetUrl . ShouldBe ( "http://github.com/Particular/GitVersion.git" ) ;
156
+ arguments . TargetBranch . ShouldBe ( "somebranch" ) ;
157
+ arguments . IsHelp . ShouldBe ( false ) ;
152
158
}
153
159
154
160
[ Test ]
@@ -162,11 +168,12 @@ public void Wrong_number_of_arguments_should_throw()
162
168
public void Unknown_argument_should_throw ( )
163
169
{
164
170
var exception = Assert . Throws < WarningException > ( ( ) => ArgumentParser . ParseArguments ( "targetDirectoryPath -x logFilePath" ) ) ;
165
- Assert . AreEqual ( "Could not parse command line parameter '-x'." , exception . Message ) ;
171
+ exception . Message . ShouldBe ( "Could not parse command line parameter '-x'." ) ;
166
172
}
167
173
168
174
[ TestCase ( "-updateAssemblyInfo true" ) ]
169
175
[ TestCase ( "-updateAssemblyInfo 1" ) ]
176
+ [ TestCase ( "-updateAssemblyInfo" ) ]
170
177
[ TestCase ( "-updateAssemblyInfo -proj foo.sln" ) ]
171
178
public void update_assembly_info_true ( string command )
172
179
{
@@ -198,23 +205,6 @@ public void update_assembly_info_with_relative_filename()
198
205
arguments . UpdateAssemblyInfoFileName . ShouldBe ( "..\\ ..\\ CommonAssemblyInfo.cs" ) ;
199
206
}
200
207
201
- [ Test ]
202
- public void update_assembly_info_with_assembly_version_format ( )
203
- {
204
- var arguments = ArgumentParser . ParseArguments ( "-updateAssemblyInfo true -assemblyVersionFormat MajorMinorPatch" ) ;
205
- arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
206
- arguments . AssemblyVersionFormat . ShouldBe ( "MajorMinorPatch" ) ;
207
- }
208
-
209
- [ Test ]
210
- public void update_assembly_info_with_filename_and_assembly_version_format ( )
211
- {
212
- var arguments = ArgumentParser . ParseArguments ( "-updateAssemblyInfo CommonAssemblyInfo.cs -assemblyVersionFormat MajorMinorPatch" ) ;
213
- arguments . UpdateAssemblyInfo . ShouldBe ( true ) ;
214
- arguments . AssemblyVersionFormat . ShouldBe ( "MajorMinorPatch" ) ;
215
- arguments . UpdateAssemblyInfoFileName . ShouldBe ( "CommonAssemblyInfo.cs" ) ;
216
- }
217
-
218
208
[ Test ]
219
209
public void can_log_to_console ( )
220
210
{
0 commit comments