Exemplo n.º 1
0
        public void BundlerServer_Responds_To_Requests_For_Bundles()
        {
            RegisterBundle();

            _Environment.RequestPath = "/bundle.js";
            _Pipeline.BuildAndCallMiddleware(_Server.AppFuncBuilder, _Environment.Environment);

            AssertBundleReturned("hello");
        }
Exemplo n.º 2
0
        public void AccessFilter_Calls_Next_Middleware_When_AccessConfiguration_Allows_Request()
        {
            Configure_Acceptable_Request();

            _Pipeline.BuildAndCallMiddleware(_Filter.AppFuncBuilder, _Environment.Environment);

            Assert.IsTrue(_Pipeline.NextMiddlewareCalled);
        }
Exemplo n.º 3
0
        public void HtmlManipulator_ManipulateResponseStream_Calls_Any_Registered_Manipulators()
        {
            var manipulator = new TextManipulator();

            _TextManipulators.Add(manipulator);

            SetResponseContent(MimeType.Html, "a");
            _Pipeline.BuildAndCallMiddleware(_HtmlManipulator.AppFuncBuilder, _Environment.Environment);

            Assert.AreEqual(1, manipulator.CallCount);
            Assert.AreSame(_Environment.Environment, manipulator.Environment);
            Assert.AreEqual("a", manipulator.TextContent.Content);
        }
Exemplo n.º 4
0
        public void AudioServer_Responds_To_Request_For_Speech_To_Text()
        {
            _Audio.Setup(r => r.SpeechToWavBytes("Hello")).Returns(_SomeBytes);
            _Environment.SetRequestUrl("/Audio", new [, ] {
                { "cmd", "say" },
                { "line", "Hello" },
            });

            _Pipeline.BuildAndCallMiddleware(_Server.AppFuncBuilder, _Environment.Environment);

            AssertAudioReturned(MimeType.WaveAudio, _SomeBytes);
        }
Exemplo n.º 5
0
        public void FileSystemServer_Serves_Files_In_SiteRoot()
        {
            var content = "Hello World!";

            AddSiteRootAndFile(@"c:\web\root", "Hello World.txt", content);
            ConfigureRequest("/Hello World.txt");

            _Pipeline.BuildAndCallMiddleware(_Server.AppFuncBuilder, _Environment.Environment);

            AssertFileReturned(MimeType.Text, content);
        }
Exemplo n.º 6
0
 public void RedirectionFilter_Passes_Request_Through_If_Path_Not_Known()
 {
     _Pipeline.BuildAndCallMiddleware(_Filter.AppFuncBuilder, _Environment.Environment);
     AssertPassedThrough();
 }
Exemplo n.º 7
0
        public void BasicAuthenticationFilter_Calls_Next_Middleware_When_Authentication_Switched_Off()
        {
            _Pipeline.BuildAndCallMiddleware(_Filter.AppFuncBuilder, _Environment);

            AssertRequestAllowed();
        }
Exemplo n.º 8
0
        public void CorsHandler_Preflight_Handles_OPTIONS_Request_From_Valid_Origin()
        {
            ConfigureCorsSupport("*");
            ConfigurePreflightRequest("http://www.allowed.com");

            _Pipeline.BuildAndCallMiddleware(_Handler.AppFuncBuilder, _Environment.Environment);

            AssertPreflightAccepted("http://www.allowed.com");
        }