public async Task ScriptsCanSetContentType() { var endpoint = new Endpoint("foo", "bar"); var responseCreator = new LiteralDynamicResponseCreator("ContentType = \"image/png\"; return \"\";", endpoint); var response = new TestableHttpResponse(); await responseCreator.CreateResponseAsync(new TestableHttpRequest("/", null), new byte[0], response, endpoint); Assert.Equal("image/png", response.ContentType); }
public async Task ScriptsCanSetResponseStatusCode() { var endpoint = new Endpoint("foo", "bar"); var responseCreator = new LiteralDynamicResponseCreator("StatusCode = 102; return \"\";", endpoint); var response = new TestableHttpResponse(); await responseCreator.CreateResponseAsync(new TestableHttpRequest("/", null), new byte[0], response, endpoint); Assert.Equal(102, (int)response.HttpStatusCode); }
public async Task ScriptWithoutReturnValueThrowsException() { var endpoint = new Endpoint("foo", "bar"); var responseCreator = new LiteralDynamicResponseCreator("ContentType = \"image/png\";", endpoint); var response = new TestableHttpResponse(); await Assert.ThrowsAsync( typeof(ArgumentNullException), async() => await responseCreator.CreateResponseAsync(new TestableHttpRequest("/", null), new byte[0], response, endpoint) ); }