Skip to content

Commit dfab1e3

Browse files
committed
Web UI: Display methods for request matcher
1 parent 3c759d6 commit dfab1e3

File tree

7 files changed

+30
-6
lines changed

7 files changed

+30
-6
lines changed

UnitTests/examples/example1/endpoint3/endpoint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616

1717
{
18-
"match": { "regex": "499" },
18+
"match": { "regex": "499", "methods": "GET" },
1919
"literal": "Hello world with 499",
2020
"statuscode": 499
2121
}

netmockery/RequestMatcher.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public abstract class RequestMatcher
2121

2222
public void SetMatchingHttpMethods(string methods) {
2323
Debug.Assert(methods != null);
24-
_matchingHttpMethods = (from part in methods.Split(' ') where part.Length > 0 select part.ToLower()).ToArray();
24+
_matchingHttpMethods = (from part in methods.Split(' ') where part.Length > 0 select part.ToUpper()).ToArray();
2525
}
2626

2727
public bool MatchesAnyHttpMethod => _matchingHttpMethods == null || _matchingHttpMethods.Length == 0;
@@ -31,7 +31,15 @@ public void SetMatchingHttpMethods(string methods) {
3131
public bool MatchesHttpMethod(string method)
3232
{
3333
Debug.Assert(method != null);
34-
return MatchesAnyHttpMethod || _matchingHttpMethods.Contains(method.ToLower());
34+
return MatchesAnyHttpMethod || _matchingHttpMethods.Contains(method.ToUpper());
35+
}
36+
37+
public IEnumerable<string> MatchingHttpMethods
38+
{
39+
get
40+
{
41+
return _matchingHttpMethods;
42+
}
3543
}
3644
}
3745

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@using netmockery
2+
@model RequestMatcher
3+
4+
@if (! Model.MatchesAnyHttpMethod)
5+
{
6+
<text><br>
7+
HTTP Methods: @( string.Join(" ", Model.MatchingHttpMethods) )
8+
</text>
9+
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
Any request
1+
@using netmockery
2+
@model RequestMatcher
3+
Any request
4+
@Html.Partial("CommonRequestMatcher", Model)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
@using netmockery
22
@model RequestMatcher
3-
Type: @Model.GetType().Name (custom view component not implemented)
3+
Type: @Model.GetType().Name (custom view component not implemented)
4+
@Html.Partial("CommonRequestMatcher", Model)

netmockery/Views/Shared/Components/RequestMatcher/RegexMatcher.cshtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
@model RegexMatcher
33

44
Evaluate regex <code>@Model.Expression</code> against <span title="request path, querystring and request body">request</span>
5+
6+
@Html.Partial("CommonRequestMatcher", Model)

netmockery/Views/Shared/Components/RequestMatcher/XPathMatcher.cshtml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ Evaluate XPath <code>@Model.XPathExpresssion</code> against request body
99
{
1010
@Model.Prefixes[i] : @Model.Namespaces[i]<br>
1111
}
12-
}
12+
}
13+
@Html.Partial("CommonRequestMatcher", Model)

0 commit comments

Comments
 (0)