@@ -8,21 +8,20 @@ namespace Microsoft.Azure.Management.ApiManagement.ArmTemplates.Test
8
8
{
9
9
public class CreateTests
10
10
{
11
-
12
- private string configExamplesFolder ;
11
+ private string invalidConfigurationFolder ;
13
12
14
13
public CreateTests ( )
15
14
{
16
- this . configExamplesFolder = String . Concat ( ".." , Path . DirectorySeparatorChar ,
17
- ".." , Path . DirectorySeparatorChar ,
15
+ this . invalidConfigurationFolder = String . Concat ( ".." , Path . DirectorySeparatorChar ,
16
+ ".." , Path . DirectorySeparatorChar ,
18
17
".." , Path . DirectorySeparatorChar ,
19
18
".." , Path . DirectorySeparatorChar ,
20
- "apimtemplate" , Path . DirectorySeparatorChar ,
21
- "Creator" , Path . DirectorySeparatorChar ,
22
- "ExampleFiles" , Path . DirectorySeparatorChar ,
23
- "YAMLConfigs" , Path . DirectorySeparatorChar ) ;
19
+ "apimtemplate.test" , Path . DirectorySeparatorChar ,
20
+ "CmdLine" , Path . DirectorySeparatorChar ,
21
+ "InvalidConfigurations" , Path . DirectorySeparatorChar ) ;
24
22
}
25
23
24
+ #region Unknown
26
25
[ Fact ]
27
26
public void ShouldFailWithUnknownCommand ( )
28
27
{
@@ -35,16 +34,18 @@ public void ShouldFailWithUnknownCommand()
35
34
public void ShouldFailWithUnknownOption ( )
36
35
{
37
36
var createCommand = new CreateCommand ( ) ;
38
- string [ ] args = new string [ ] { "--configurationFile" , String . Concat ( this . configExamplesFolder , "valid .yml" ) } ;
37
+ string [ ] args = new string [ ] { "--configurationFile" , String . Concat ( this . invalidConfigurationFolder , "invalidVersionSetDisplayName .yml" ) } ;
39
38
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
40
39
Assert . Contains ( "Unrecognized option '--configurationFile'" , ex . Message ) ;
41
40
}
41
+ #endregion
42
42
43
+ #region BaseProperties
43
44
[ Fact ]
44
45
public void ShouldFailWithInvalidOutputLocation ( )
45
46
{
46
47
var createCommand = new CreateCommand ( ) ;
47
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidOutputLocation.yml" ) } ;
48
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidOutputLocation.yml" ) } ;
48
49
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
49
50
Assert . Contains ( "Output location is required" , ex . Message ) ;
50
51
}
@@ -53,7 +54,7 @@ public void ShouldFailWithInvalidOutputLocation()
53
54
public void ShouldFailWithInvalidVersion ( )
54
55
{
55
56
var createCommand = new CreateCommand ( ) ;
56
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidVersion.yml" ) } ;
57
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidVersion.yml" ) } ;
57
58
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
58
59
Assert . Contains ( "Version is required" , ex . Message ) ;
59
60
}
@@ -62,16 +63,27 @@ public void ShouldFailWithInvalidVersion()
62
63
public void ShouldFailWithInvalidAPIMServiceName ( )
63
64
{
64
65
var createCommand = new CreateCommand ( ) ;
65
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidAPIMServiceName.yml" ) } ;
66
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidAPIMServiceName.yml" ) } ;
66
67
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
67
68
Assert . Contains ( "APIM service name is required" , ex . Message ) ;
68
69
}
69
70
71
+ [ Fact ]
72
+ public void ShouldFailWithInvalidLinking ( )
73
+ {
74
+ var createCommand = new CreateCommand ( ) ;
75
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidLinking.yml" ) } ;
76
+ var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
77
+ Assert . Contains ( "LinkTemplatesBaseUrl is required for linked templates" , ex . Message ) ;
78
+ }
79
+ #endregion
80
+
81
+ #region API
70
82
[ Fact ]
71
83
public void ShouldFailWithInvalidAPIConfiguration ( )
72
84
{
73
85
var createCommand = new CreateCommand ( ) ;
74
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidAPI.yml" ) } ;
86
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidAPI.yml" ) } ;
75
87
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
76
88
Assert . Contains ( "API configuration is required" , ex . Message ) ;
77
89
}
@@ -80,7 +92,7 @@ public void ShouldFailWithInvalidAPIConfiguration()
80
92
public void ShouldFailWithInvalidOpenAPISpec ( )
81
93
{
82
94
var createCommand = new CreateCommand ( ) ;
83
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidOpenAPISpec.yml" ) } ;
95
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidOpenAPISpec.yml" ) } ;
84
96
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
85
97
Assert . Contains ( "Open API Spec is required" , ex . Message ) ;
86
98
}
@@ -89,7 +101,7 @@ public void ShouldFailWithInvalidOpenAPISpec()
89
101
public void ShouldFailWithInvalidSuffix ( )
90
102
{
91
103
var createCommand = new CreateCommand ( ) ;
92
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidSuffix.yml" ) } ;
104
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidSuffix.yml" ) } ;
93
105
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
94
106
Assert . Contains ( "API suffix is required" , ex . Message ) ;
95
107
}
@@ -98,54 +110,83 @@ public void ShouldFailWithInvalidSuffix()
98
110
public void ShouldFailWithInvalidAPIName ( )
99
111
{
100
112
var createCommand = new CreateCommand ( ) ;
101
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidAPIName.yml" ) } ;
113
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidAPIName.yml" ) } ;
102
114
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
103
115
Assert . Contains ( "API name is required" , ex . Message ) ;
104
116
}
105
117
106
118
[ Fact ]
107
- public void ShouldFailWithInvalidLinking ( )
119
+ public void ShouldFailWithInvalidOperationPolicy ( )
108
120
{
109
121
var createCommand = new CreateCommand ( ) ;
110
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidLinking .yml" ) } ;
122
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidOperationPolicy .yml" ) } ;
111
123
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
112
- Assert . Contains ( "LinkTemplatesBaseUrl is required for linked templates" , ex . Message ) ;
124
+ Assert . Contains ( "Policy XML is required if an API operation is provided" , ex . Message ) ;
125
+ }
126
+
127
+ [ Fact ]
128
+ public void ShouldFailWithInvalidDiagnosticLoggerId ( )
129
+ {
130
+ var createCommand = new CreateCommand ( ) ;
131
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidDiagnosticLoggerId.yml" ) } ;
132
+ var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
133
+ Assert . Contains ( "LoggerId is required if an API diagnostic is provided" , ex . Message ) ;
113
134
}
135
+ #endregion
114
136
137
+ #region APIVersionSet
115
138
[ Fact ]
116
139
public void ShouldFailWithInvalidVersionSetDisplayName ( )
117
140
{
118
141
var createCommand = new CreateCommand ( ) ;
119
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidVersionSetDisplayName.yml" ) } ;
142
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidVersionSetDisplayName.yml" ) } ;
120
143
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
121
144
Assert . Contains ( "Display name is required if an API Version Set is provided" , ex . Message ) ;
122
145
}
146
+ #endregion
123
147
148
+ #region Product
124
149
[ Fact ]
125
- public void ShouldFailWithInvalidVersionSetVersioningScheme ( )
150
+ public void ShouldFailWithInvalidProductDisplayName ( )
126
151
{
127
152
var createCommand = new CreateCommand ( ) ;
128
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidVersionSetVersioningScheme .yml" ) } ;
153
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidProductDisplayName .yml" ) } ;
129
154
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
130
- Assert . Contains ( "Versioning scheme is required if an API Version Set is provided" , ex . Message ) ;
155
+ Assert . Contains ( "Display name is required if an Product is provided" , ex . Message ) ;
131
156
}
157
+ #endregion
132
158
159
+ #region Logger
133
160
[ Fact ]
134
- public void ShouldFailWithInvalidOperationPolicy ( )
161
+ public void ShouldFailWithInvalidLoggerDisplayName ( )
135
162
{
136
163
var createCommand = new CreateCommand ( ) ;
137
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidOperationPolicy .yml" ) } ;
164
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidLoggerName .yml" ) } ;
138
165
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
139
- Assert . Contains ( "Policy XML is required if an API operation is provided" , ex . Message ) ;
166
+ Assert . Contains ( "Name is required if an Logger is provided" , ex . Message ) ;
140
167
}
168
+ #endregion
141
169
170
+ #region Backend
142
171
[ Fact ]
143
- public void ShouldFailWithInvalidDiagnosticLoggerId ( )
172
+ public void ShouldFailWithInvalidBackendDisplayName ( )
144
173
{
145
174
var createCommand = new CreateCommand ( ) ;
146
- string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . configExamplesFolder , "invalidDiagnosticLoggerId .yml" ) } ;
175
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidBackendTitle .yml" ) } ;
147
176
var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
148
- Assert . Contains ( "LoggerId is required if an API diagnostic is provided" , ex . Message ) ;
177
+ Assert . Contains ( "Title is required if a Backend is provided" , ex . Message ) ;
178
+ }
179
+ #endregion
180
+
181
+ #region AuthorizationServer
182
+ [ Fact ]
183
+ public void ShouldFailWithInvalidAuthorizationServerDisplayName ( )
184
+ {
185
+ var createCommand = new CreateCommand ( ) ;
186
+ string [ ] args = new string [ ] { "--configFile" , String . Concat ( this . invalidConfigurationFolder , "invalidAuthorizationServerDisplayName.yml" ) } ;
187
+ var ex = Assert . ThrowsAny < CommandParsingException > ( ( ) => createCommand . Execute ( args ) ) ;
188
+ Assert . Contains ( "Display name is required if an Authorization Server is provided" , ex . Message ) ;
149
189
}
190
+ #endregion
150
191
}
151
192
}
0 commit comments