diff --git a/SimpleHttpServerTest/SimpleServerTest.cs b/SimpleHttpServerTest/SimpleServerTest.cs index 5cf42e4..4f1a209 100644 --- a/SimpleHttpServerTest/SimpleServerTest.cs +++ b/SimpleHttpServerTest/SimpleServerTest.cs @@ -77,6 +77,19 @@ public class SimpleServerTest { } } + [TestMethod] + public async Task CheckQueryArgs() { + foreach (var a1 in "test1;longstring2;something else with a space".Split(';')) { + foreach (var a2 in new[] { -10, 2, -2, 5, 0, 4 }) { + foreach (var a3 in new[] { -1, 9, 2, -20, 0 }) { + var resp = await AssertGetStatusCodeAsync($"returnqueries?arg1={a1}&arg2={a2}&arg3={a3}", HttpStatusCode.OK); + var str = await resp.Content.ReadAsStringAsync(); + Assert.AreEqual(TestEndpoints.GetReturnQueryPageResult(a1, a2, a3), str); + } + } + } + } + public class TestEndpoints { [HttpEndpoint(HttpRequestType.GET, "/", "index.html")] public static async Task Index(RequestContext req) { @@ -101,5 +114,13 @@ public class SimpleServerTest { public static async Task TestPage3(RequestContext req) { await req.RespWriter.WriteAsync(GetHttpPageContentFromPrefix("testpage3")); } + + + public static string GetReturnQueryPageResult(string arg1, int arg2, int arg3) => $"{arg1};{arg2 * 2 - arg3 * 5}"; + + [HttpEndpoint(HttpRequestType.GET, "/returnqueries")] + public static async Task TestPage3(RequestContext req, string arg1, int arg2, int arg3) { + await req.RespWriter.WriteAsync(GetReturnQueryPageResult(arg1, arg2, arg3)); + } } } \ No newline at end of file