Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
 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)
         );
 }