예제 #1
0
        public void LoadsSingleNullableGuidCookieUsingPropertyName()
        {
            var expected = new Guid("{6B6CB3A7-CFD7-4479-90C8-440D9F1B9F33}");
            var request  = new MockRequest
            {
                Headers = new Dictionary <string, string[]> {
                    { "Cookie", new[] { "Test=" + expected.ToString() } }
                }
            };
            var context = new MockContext {
                Request = request
            };

            var runner = new HandlerRunnerBuilder(typeof(SingleNullableGuidCookieHandler), "GET").BuildRunner();
            var target = new SingleNullableGuidCookieHandler();

            try
            {
                runner(target, context);
            }
            catch (ArgumentNullException)
            {
                // Content-type handling is going to throw an exception here.
            }
            Assert.Equal(expected, target.Test);
        }
 public void CallsFooImplementation()
 {
     var target = new HandlerRunnerBuilder(typeof (Foo), "GET").BuildRunner();
     var context = new Mocks.MockContext();
     context.Request = new MockRequest { Headers = new Dictionary<string, string[]> { { HeaderKeys.Accept, new[] { "text/html" } } } };
     var foo = new Foo();
     target(foo, context);
     Assert.True(foo.Called);
 }
 public void CallsFooImplementation()
 {
     var target = new HandlerRunnerBuilder(typeof (Foo), "GET").BuildRunner();
     var context = new Mocks.MockContext();
     context.Request = new MockRequest {AcceptTypes = new[] {"text/html"}};
     var foo = new Foo();
     target(foo, context);
     Assert.True(foo.Called);
 }
 public void BarStopsFoo()
 {
     var target = new HandlerRunnerBuilder(typeof (Bar), "GET").BuildRunner();
     var context = new Mocks.MockContext();
     context.Request = new MockRequest { Headers = new Dictionary<string, string[]> { { HeaderKeys.Accept, new[] { "text/html" } } } };
     var bar = new Bar();
     target(bar, context);
     Assert.True(((IBar)bar).Called);
     Assert.False(((IFoo)bar).Called);
 }
 public void BarStopsFoo()
 {
     var target = new HandlerRunnerBuilder(typeof (Bar), "GET").BuildRunner();
     var context = new Mocks.MockContext();
     context.Request = new MockRequest {AcceptTypes = new[] {"text/html"}};
     var bar = new Bar();
     target(bar, context);
     Assert.True(((IBar)bar).Called);
     Assert.False(((IFoo)bar).Called);
 }
예제 #6
0
        private static void Run <T>(T handler, IContext context)
        {
            var runner = new HandlerRunnerBuilder(typeof(T), "GET").BuildRunner();

            try
            {
                runner(handler, context);
            }
            catch (ArgumentNullException)
            {
                // Content-type handling is going to throw an exception here.
            }
        }
예제 #7
0
        public void CallsFooImplementation()
        {
            var target  = new HandlerRunnerBuilder(typeof(StringFoo), "GET").BuildRunner();
            var context = new Mocks.MockContext {
                Request = new MockRequest {
                    Headers = new Dictionary <string, string[]> {
                        { HeaderKeys.Accept, new[] { "text/html" } }
                    }
                }
            };
            var foo = new StringFoo();

            target(foo, context);
            Assert.True(foo.Called);
        }
        public void RedirectFooRedirects()
        {
            var target  = new HandlerRunnerBuilder(typeof(RedirectFoo), "GET").BuildRunner();
            var context = new Mocks.MockContext();

            context.Request = new MockRequest {
                Headers = new Dictionary <string, string[]> {
                    { HeaderKeys.Accept, new[] { "text/html" } }
                }
            };
            context.Response = new MockResponse();
            var foo = new RedirectFoo();

            target(foo, context);
            Assert.True(context.Response.Headers.ContainsKey("Location"));
        }
        public void BarStopsFoo()
        {
            var target  = new HandlerRunnerBuilder(typeof(Bar), "GET").BuildRunner();
            var context = new Mocks.MockContext();

            context.Request = new MockRequest {
                Headers = new Dictionary <string, string[]> {
                    { HeaderKeys.Accept, new[] { "text/html" } }
                }
            };
            var bar = new Bar();

            target(bar, context);
            Assert.True(((IBar)bar).Called);
            Assert.False(((IFoo)bar).Called);
        }
        public void CallsPutWithParameter()
        {
            var target  = new HandlerRunnerBuilder(typeof(PutFoo), "PUT").BuildRunner();
            var context = new Mocks.MockContext();

            context.Request = new MockRequest {
                Headers = new Dictionary <string, string[]> {
                    { HeaderKeys.Accept, new[] { "text/html" } }, { HeaderKeys.ContentType, new[] { "application/json" } }
                },
                InputStream = new MemoryStream(TestJson)
            };
            var postFoo = new PutFoo();

            target(postFoo, context);
            Assert.True(postFoo.Called);
            Assert.Equal("Pass", postFoo.Test);
        }
예제 #11
0
        public void LoadsSingleNullGuidCookieUsingPropertyName()
        {
            var request = new MockRequest();
            var context = new MockContext {
                Request = request
            };

            var runner = new HandlerRunnerBuilder(typeof(SingleNullableGuidCookieHandler), "GET").BuildRunner();
            var target = new SingleNullableGuidCookieHandler();

            try
            {
                runner(target, context);
            }
            catch (ArgumentNullException)
            {
                // Content-type handling is going to throw an exception here.
            }
            Assert.False(target.Test.HasValue);
        }
예제 #12
0
        public void LoadsSingleStringCookieUsingPropertyName()
        {
            var request = new MockRequest {
                Headers = new Dictionary <string, string[]> {
                    { "Cookie", new[] { "Test=Pass" } }
                }
            };
            var context = new MockContext {
                Request = request
            };

            var runner = new HandlerRunnerBuilder(typeof(SingleStringCookieHandler), "GET").BuildRunner();
            var target = new SingleStringCookieHandler();

            try
            {
                runner(target, context);
            }
            catch (ArgumentNullException)
            {
                // Content-type handling is going to throw an exception here.
            }
            Assert.Equal("Pass", target.Test);
        }