public void should_match(string path, string method, string pattern, string[] expectedTokenKeys, string[] expectedTokenValues) { var request = new StubHttpRequest { Method = method, Path = path }; var result = request.IsFor("GET", pattern, out var tokens); Assert.True(result); Assert.AreEqual(expectedTokenKeys.Length, tokens.Count); for (var i = 0; i < expectedTokenKeys.Length; i++) { Assert.AreEqual(expectedTokenValues[i], tokens[expectedTokenKeys[i]]); } }
public void setup_before_each_test() { IHeaderDictionary headers = new HeaderDictionary(new Dictionary <string, StringValues> { { "User-Agent", new StringValues("my-user-agent") } }); var httpRequest = new StubHttpRequest(headers) { Method = "GET", Path = "/ping", QueryString = new QueryString("?v=1") }; var httpResponse = new StubHttpResponse { StatusCode = 23 }; _httpContext = new StubHttpContext(httpRequest, httpResponse); _logger = new StubLogger <JsonLoggingHttpServerEventCallback>(); _testSubject = new JsonLoggingHttpServerEventCallback(_logger); }
public void should_match(string urlEncodedPath, string method, string pattern, string[] expectedTokenKeys, string[] expectedTokenValues, string expectedRemainder) { // PathString seemingly automatically encodes the string even if it's already encoded var request = new StubHttpRequest { Method = method, Path = WebUtility.UrlDecode(urlEncodedPath) }; IDictionary <string, string> tokens; PathString remainder; var result = request.IsFor(method, pattern, out tokens, out remainder); result.ShouldBe(true); tokens.Count.ShouldBe(expectedTokenKeys.Length); for (var i = 0; i < expectedTokenKeys.Length; i++) { Assert.AreEqual(expectedTokenValues[i], tokens[expectedTokenKeys[i]]); } remainder.ToString().ShouldBe(expectedRemainder); }
public SendExpression(HttpContext context) { _request = context.Request.As <StubHttpRequest>(); }