forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpMethodHelperTest.cs
More file actions
66 lines (60 loc) · 2.13 KB
/
Copy pathHttpMethodHelperTest.cs
File metadata and controls
66 lines (60 loc) · 2.13 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
66
// 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.Http;
using Microsoft.TestCommon;
namespace System.Web.Http
{
public class HttpMethodHelperTest
{
public static TheoryDataSet<string, HttpMethod> CommonHttpMethods
{
get
{
return new TheoryDataSet<string, HttpMethod>
{
{ "Get", HttpMethod.Get },
{ "Post", HttpMethod.Post },
{ "Put", HttpMethod.Put },
{ "Delete", HttpMethod.Delete },
{ "Head", HttpMethod.Head },
{ "Options", HttpMethod.Options },
{ "Trace", HttpMethod.Trace },
};
}
}
public static TheoryDataSet<string> UncommonHttpMethods
{
get
{
return new TheoryDataSet<string>
{
"Debug",
"Patch",
"Connect",
"Random",
"M-Get",
};
}
}
[Fact]
public void GetHttpMethod_ReturnsNullOnNullorEmpty()
{
Assert.Null(HttpMethodHelper.GetHttpMethod(null));
Assert.Null(HttpMethodHelper.GetHttpMethod(String.Empty));
}
[Theory]
[PropertyData("CommonHttpMethods")]
public void GetHttpMethod_RetunsStaticResult(string method, HttpMethod expectedMethod)
{
Assert.Same(expectedMethod, HttpMethodHelper.GetHttpMethod(method));
Assert.Same(expectedMethod, HttpMethodHelper.GetHttpMethod(method.ToLowerInvariant()));
Assert.Same(expectedMethod, HttpMethodHelper.GetHttpMethod(method.ToUpperInvariant()));
}
[Theory]
[PropertyData("UncommonHttpMethods")]
public void GetHttpMethod_RetunsNonStaticResult(string method)
{
Assert.Equal(method, HttpMethodHelper.GetHttpMethod(method).ToString());
}
}
}