forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiExplorerSettingsTest.cs
More file actions
65 lines (56 loc) · 2.92 KB
/
Copy pathApiExplorerSettingsTest.cs
File metadata and controls
65 lines (56 loc) · 2.92 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// 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.Collections.Generic;
using System.Net.Http;
using System.Web.Http.Description;
using System.Web.Http.Dispatcher;
using Microsoft.TestCommon;
namespace System.Web.Http.ApiExplorer
{
public class ApiExplorerSettingsTest
{
public static IEnumerable<object[]> HiddenController_DoesNotShowUpOnDescription_PropertyData
{
get
{
object controllerType = typeof(HiddenController);
object expectedApiDescriptions = new List<object>();
yield return new[] { controllerType, expectedApiDescriptions };
}
}
[Theory]
[PropertyData("HiddenController_DoesNotShowUpOnDescription_PropertyData")]
public void HiddenController_DoesNotShowUpOnDescription(Type controllerType, List<object> expectedResults)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("Default", "{controller}/{id}", new { id = RouteParameter.Optional });
DefaultHttpControllerSelector controllerSelector = ApiExplorerHelper.GetStrictControllerSelector(config, controllerType);
config.Services.Replace(typeof(IHttpControllerSelector), controllerSelector);
IApiExplorer explorer = config.Services.GetApiExplorer();
ApiExplorerHelper.VerifyApiDescriptions(explorer.ApiDescriptions, expectedResults);
}
public static IEnumerable<object[]> HiddenAction_DoesNotShowUpOnDescription_PropertyData
{
get
{
object controllerType = typeof(HiddenActionController);
object expectedApiDescriptions = new List<object>
{
new { HttpMethod = HttpMethod.Get, RelativePath = "HiddenAction/{id}", HasRequestFormatters = false, HasResponseFormatters = true, NumberOfParameters = 1}
};
yield return new[] { controllerType, expectedApiDescriptions };
}
}
[Theory]
[PropertyData("HiddenAction_DoesNotShowUpOnDescription_PropertyData")]
public void HiddenAction_DoesNotShowUpOnDescription(Type controllerType, List<object> expectedResults)
{
HttpConfiguration config = new HttpConfiguration();
config.Routes.MapHttpRoute("Default", "{controller}/{id}", new { id = RouteParameter.Optional });
DefaultHttpControllerSelector controllerSelector = ApiExplorerHelper.GetStrictControllerSelector(config, controllerType);
config.Services.Replace(typeof(IHttpControllerSelector), controllerSelector);
IApiExplorer explorer = config.Services.GetApiExplorer();
ApiExplorerHelper.VerifyApiDescriptions(explorer.ApiDescriptions, expectedResults);
}
}
}