Esempio n. 1
0
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake<INancyEngine>();

            this.fakeBootstrapper = A.Fake<INancyBootstrapper>();

            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            this.environment = new Dictionary<string, object>()
                                   {
                                       { "owin.RequestMethod", "GET" },
                                       { "owin.RequestPath", "/test" },
                                       { "owin.RequestPathBase", "/root" },
                                       { "owin.RequestQueryString", "var=value" },
                                       { "owin.RequestHeaders", new Dictionary<string, string> { { "Host", "testserver" } } },
                                       { "owin.RequestBody", null },
                                       { "owin.RequestScheme", "http" },
                                       { "owin.Version", "1.0" }
                                   };
        }
Esempio n. 2
0
        private static Task OnComponent(IDictionary<string, object> env, Func<IDictionary<string, object>, Task> next)
        {
            var nancyOptions = new NancyOptions { Bootstrapper = new DefaultNancyBootstrapper() };

            var nancyHost = new NancyOwinHost(next, nancyOptions);
            return nancyHost.Invoke(env);
        }
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake <INancyEngine>();

            this.fakeBootstrapper = A.Fake <INancyBootstrapper>();

            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            var tcs = new TaskCompletionSource <object>();

            this.environment = new Dictionary <string, object>()
            {
                { "owin.RequestMethod", "GET" },
                { "owin.RequestPath", "/test" },
                { "owin.RequestPathBase", "/root" },
                { "owin.RequestQueryString", "var=value" },
                { "owin.RequestBody", Stream.Null },
                { "owin.RequestHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
                { "owin.RequestScheme", "http" },
                { "owin.ResponseHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
                { "owin.ResponseBody", Stream.Null },
                { "owin.Version", "1.0" },
                { "owin.CallCancelled", CancellationToken.None }
            };

            this.requestHeaders = new Dictionary <string, string[]> {
                { "Host", new[] { "testserver" } }
            };
        }
Esempio n. 4
0
        public NancyOwinHostFixture()
        {
            this.fakeEngine = A.Fake <INancyEngine>();

            this.fakeBootstrapper = A.Fake <INancyBootstrapper>();
            A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);

            this.host = new NancyOwinHost(fakeBootstrapper);

            this.fakeResponseCallback = (status, headers, bodyDelegate) => { };

            this.fakeErrorCallback = (ex) => { };

            this.environment = new Dictionary <string, object>()
            {
                { "owin.RequestMethod", "GET" },
                { "owin.RequestPath", "/test" },
                { "owin.RequestPathBase", "/root" },
                { "owin.RequestQueryString", "var=value" },
                { "owin.RequestHeaders", new Dictionary <string, string>() },
                { "owin.RequestBody", null },
                { "owin.RequestScheme", "http" },
                { "owin.Version", "1.0" }
            };
        }
Esempio n. 5
0
        private static Task OnComponent(IDictionary <string, object> env, Func <IDictionary <string, object>, Task> next)
        {
            var nancyOptions = new NancyOptions {
                Bootstrapper = new DefaultNancyBootstrapper()
            };

            var nancyHost = new NancyOwinHost(next, nancyOptions);

            return(nancyHost.Invoke(env));
        }
Esempio n. 6
0
 public NancyOwinHostFixture()
 {
     this.fakeEngine       = A.Fake <INancyEngine>();
     this.fakeBootstrapper = A.Fake <INancyBootstrapper>();
     A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine);
     this.host = new NancyOwinHost(null, new NancyOptions {
         Bootstrapper = this.fakeBootstrapper
     });
     this.environment = new Dictionary <string, object>
     {
         { "owin.RequestMethod", "GET" },
         { "owin.RequestPath", "/test" },
         { "owin.RequestPathBase", "/root" },
         { "owin.RequestQueryString", "var=value" },
         { "owin.RequestBody", Stream.Null },
         { "owin.RequestHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
         { "owin.RequestScheme", "http" },
         { "owin.ResponseHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) },
         { "owin.ResponseBody", new MemoryStream() },
         { "owin.ResponseReasonPhrase", string.Empty },
         { "owin.Version", "1.0" },
         { "owin.CallCancelled", CancellationToken.None }
     };
 }