Пример #1
0
        public void BundlerServer_Responds_To_Requests_For_Bundles()
        {
            RegisterBundle();

            _Environment.RequestPath = "/bundle.js";
            _Pipeline.CallMiddleware(_Server.HandleRequest, _Environment.Environment);

            AssertBundleReturned("hello");
        }
Пример #2
0
        public void AccessFilter_Calls_Next_Middleware_When_AccessConfiguration_Allows_Request()
        {
            Configure_Acceptable_Request();

            _Pipeline.CallMiddleware(_Filter.FilterRequest, _Environment.Environment);

            Assert.IsTrue(_Pipeline.NextMiddlewareCalled);
        }
Пример #3
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.CallMiddleware(_Server.HandleRequest, _Environment.Environment);

            AssertAudioReturned(MimeType.WaveAudio, _SomeBytes);
        }
        public void BasicAuthenticationFilter_Calls_Next_Middleware_When_Authentication_Switched_Off()
        {
            _Pipeline.CallMiddleware(_Filter.FilterRequest, _Environment);

            AssertRequestAllowed();
        }
Пример #5
0
        public void CorsHandler_Preflight_Handles_OPTIONS_Request_From_Valid_Origin()
        {
            ConfigureCorsSupport("*");
            ConfigurePreflightRequest("http://www.allowed.com");

            _Pipeline.CallMiddleware(_Handler.HandleRequest, _Environment.Environment);

            AssertPreflightAccepted("http://www.allowed.com");
        }
Пример #6
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.CallMiddleware(_Server.HandleRequest, _Environment.Environment);

            AssertFileReturned(MimeType.Text, content);
        }
Пример #7
0
 public void RedirectionFilter_Passes_Request_Through_If_Path_Not_Known()
 {
     _Pipeline.CallMiddleware(_Filter.FilterRequest, _Environment.Environment);
     AssertPassedThrough();
 }
Пример #8
0
 public void ExceptionHandler_Calls_Next_Middleware()
 {
     _Pipeline.CallMiddleware(_ExceptionHandler.HandleRequest, _Environment.Environment);
     Assert.IsTrue(_Pipeline.NextMiddlewareCalled);
 }
Пример #9
0
        public void ImageServer_Serves_All_Stock_Resource_Images()
        {
            var worksheet              = new ExcelWorksheetData(TestContext);
            var requestImageName       = worksheet.String("RequestImageName");
            var stockImagePropertyName = worksheet.String("StockImage");

            var cloneMethod   = typeof(Images).GetMethod($"Clone_{stockImagePropertyName}", new Type[0]);
            var expectedImage = (Bitmap)cloneMethod.Invoke(null, new object[0]);

            try {
                _Environment.RequestPath = $"/Images/{requestImageName}.png";
                _Pipeline.CallMiddleware(_Server.HandleRequest, _Environment.Environment);

                using (var stream = new MemoryStream(_Environment.ResponseBodyBytes)) {
                    using (var siteImage = (Bitmap)Bitmap.FromStream(stream)) {
                        AssertImagesAreIdentical(expectedImage, siteImage);
                    }
                }
            } finally {
                expectedImage.Dispose();
            }
        }
Пример #10
0
 public void ResponseStreamWrapper_WrapResponseStream_Always_Calls_Next_Middleware()
 {
     InitialiseWrapper();
     _Pipeline.CallMiddleware(_Wrapper.WrapResponseStream, _Environment.Environment);
     Assert.IsTrue(_Pipeline.NextMiddlewareCalled);
 }