Beispiel #1
0
        public async Task It_serializes_web_api_model()
        {
            Action <SwaggerDocsConfig> config = c => c.DocumentFilter <ApplySharedModelsDocumentation>();

            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => SharedModelsSetup.ConfigurationWithFormatters(appBuilder, config, typeof(SharedModelsSetup.SharedModelsController), typeof(SharedModelsSetup.SharedModelsWebApiController))))
            {
                // Access swagger doc first
                await ValidationUtils.ValidateSwaggerJson();

                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the custom web api model can be serialized
                var webApiResults = await httpClient.GetJsonAsync <List <SharedModelsSetup.CustomApiModel> >("CustomApiModels");

                webApiResults.Should().NotBeNull();
                webApiResults.Count.Should().Be(2);
            }
        }
        public async Task It_consolidates_tags_in_final_swagger_model()
        {
            Action <SwaggerDocsConfig> config = c => c.DocumentFilter <ApplySharedModelsDocumentation>();

            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => SharedModelsSetup.Configuration(appBuilder, config, typeof(SharedModelsSetup.SharedModelsController), typeof(SharedModelsSetup.SharedModelsWebApiController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the OData route in the test controller is valid
                var results = await httpClient.GetJsonAsync <ODataResponse <List <SharedModelsSetup.SharedModel> > >("odata/SharedModels");

                results.Should().NotBeNull();
                results.Value.Count.Should().Be(4);

                // Verify that the WebApi route in the test controller is valid
                var webApiResults = await httpClient.GetJsonAsync <List <SharedModelsSetup.SharedModel> >("SharedModels");

                webApiResults.Should().NotBeNull();
                webApiResults.Count.Should().Be(4);

                // Act and Assert
                await ValidationUtils.ValidateSwaggerJson();
            }
        }