Exemplo n.º 1
0
        public void SetsCookieFromSingleValueProperty()
        {
            var request  = new MockRequest();
            var response = new MockResponse();
            var context  = new MockContext {
                Request = request, Response = response
            };
            var handler = new SingleStringCookieHandler {
                Test = "Pass"
            };

            Run(handler, context);
            string[] cookies;
            Assert.True(response.Headers.TryGetValue(HeaderKeys.SetCookie, out cookies));
            Assert.True(cookies.Any(c => c.StartsWith("Test=Pass;")));
        }
Exemplo n.º 2
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);
        }