Beispiel #1
0
        public void BundlerServer_Responds_To_Requests_For_Bundles()
        {
            RegisterBundle();

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

            AssertBundleReturned("hello");
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #6
0
 public void RedirectionFilter_Passes_Request_Through_If_Path_Not_Known()
 {
     _Pipeline.BuildAndCallMiddleware(_Filter.AppFuncBuilder, _Environment.Environment);
     AssertPassedThrough();
 }
Beispiel #7
0
        public void BasicAuthenticationFilter_Calls_Next_Middleware_When_Authentication_Switched_Off()
        {
            _Pipeline.BuildAndCallMiddleware(_Filter.AppFuncBuilder, _Environment);

            AssertRequestAllowed();
        }
Beispiel #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");
        }