Skip to content

Commit 3d4d94d

Browse files
committed
Fixing SwaggerUiConfigExtensionTests.SwaggerUiDocs
1 parent 1e69181 commit 3d4d94d

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

test/Microsoft.Azure.Mobile.Server.Swagger.Test/SwaggerUiConfigExtensionsTests.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,22 @@ public async Task SwaggerUiDocs()
2525
c.MobileAppUi(config);
2626
});
2727

28-
string o2cExpected = GetResourceString("Microsoft.Azure.Mobile.Server.Swagger.o2c.html");
29-
// string oauthExpected = GetResourceString("Microsoft.Azure.Mobile.Server.Swagger.swagger-oauth.js");
28+
await ValidateResource(server, "Microsoft.Azure.Mobile.Server.Swagger.o2c.html", "http://localhost/swagger/ui/o2c-html");
29+
await ValidateResource(server, "Microsoft.Azure.Mobile.Server.Swagger.swagger-ui.min.js", "http://localhost/swagger/ui/swagger-ui-min-js");
3030

31-
// Act
32-
var o2cResponse = await server.HttpClient.GetAsync("http://localhost/swagger/ui/o2c-html");
33-
// var oauthResponse = await server.HttpClient.GetAsync("http://localhost/swagger/ui/lib/swagger-oauth-js");
31+
Assert.Contains(typeof(SwaggerUiSecurityFilter), config.MessageHandlers.Select(h => h.GetType()));
32+
}
3433

35-
string o2c = await o2cResponse.Content.ReadAsStringAsync();
36-
// string oauth = await oauthResponse.Content.ReadAsStringAsync();
34+
private static async Task ValidateResource(TestServer server, string resource, string requestUri)
35+
{
36+
string expected = GetResourceString(resource);
37+
38+
// Act
39+
var response = await server.HttpClient.GetAsync(requestUri);
40+
string actual = await response.Content.ReadAsStringAsync();
3741

3842
// Assert
39-
Assert.Equal(o2cExpected, o2c);
40-
// Assert.Equal(oauthExpected, oauth);
41-
Assert.Contains(typeof(SwaggerUiSecurityFilter), config.MessageHandlers.Select(h => h.GetType()));
43+
Assert.Equal(expected, actual);
4244
}
4345

4446
[SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "This code is resilient to this scenario")]

0 commit comments

Comments
 (0)