forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathControllerConfigurationTest.cs
More file actions
38 lines (35 loc) · 1.88 KB
/
Copy pathControllerConfigurationTest.cs
File metadata and controls
38 lines (35 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.TestCommon;
namespace System.Web.Http
{
public class ControllerConfigurationTest
{
[Theory]
[InlineData("SpecialConfig/GetFormattersCount_ControllerConfig", 1)]
[InlineData("RegularConfig/GetFormattersCount_ControllerConfig", 4)]
[InlineData("SpecialConfig/GetParameterRulesCount_ControllerConfig", 0)]
[InlineData("RegularConfig/GetParameterRulesCount_ControllerConfig", 3)]
[InlineData("SpecialConfig/GetServicesCount_ControllerConfig", 1)]
[InlineData("RegularConfig/GetServicesCount_ControllerConfig", 0)]
[InlineData("SpecialConfig/GetFormattersCount_RequestConfig", 1)]
[InlineData("RegularConfig/GetFormattersCount_RequestConfig", 4)]
[InlineData("SpecialConfig/GetParameterRulesCount_RequestConfig", 0)]
[InlineData("RegularConfig/GetParameterRulesCount_RequestConfig", 3)]
[InlineData("SpecialConfig/GetServicesCount_RequestConfig", 1)]
[InlineData("RegularConfig/GetServicesCount_RequestConfig", 0)]
public async Task ControllerConfigurationSettings_ArePropagatedTo_ControllerAndRequest(string requestUrl, int count)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("Default", "{controller}/{action}");
HttpServer server = new HttpServer(config);
HttpClient client = new HttpClient(server);
HttpResponseMessage response = await client.GetAsync("http://localhost/" + requestUrl);
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
Assert.Equal(count, await response.Content.ReadAsAsync<int>());
}
}
}