Пример #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);
        }
Пример #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);
        }
Пример #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)
         );
 }