public GenericFileResponseFixture(ITestOutputHelper output)
        {
            var environment = new DefaultNancyEnvironment();
            environment.StaticContent(safepaths: this.GetLocation());

            this.context = new NancyContext { Environment = environment };

            this.filePath = this.GetFilePath();
        }
        public GenericFileResponseFixture(ITestOutputHelper output)
        {
            var environment = new DefaultNancyEnvironment();

            environment.StaticContent(safepaths: this.GetLocation());

            this.context = new NancyContext {
                Environment = environment
            };

            this.filePath = this.GetFilePath();
        }
Esempio n. 3
0
        public GenericFileResponseFixture()
        {
            var assemblyPath =
                Path.GetDirectoryName(this.GetType().Assembly.Location);
            
            var environment = new DefaultNancyEnvironment();
            environment.StaticContent(safepaths:assemblyPath);

            this.context = new NancyContext { Environment = environment };

            this.imagePath =
                Path.GetFileName(this.GetType().Assembly.Location);
        }
        public void Should_use_filename_and_content_type_for_attachments_from_file_response_if_not_overridden()
        {
            // Given
            var environment = new DefaultNancyEnvironment();
            environment.StaticContent(safepaths:this.GetLocation());

            var filename = this.GetFilePath();
            var response = new GenericFileResponse(filename, "foo/bar", new NancyContext() {Environment = environment});

            // When
            var result = response.AsAttachment();

            // Then
            result.Headers["Content-Disposition"].ShouldContain(Path.GetFileName(filename));
            result.ContentType.ShouldEqual("foo/bar");
        }
        public GenericFileResponseFixture()
        {
            var assemblyPath =
                Path.GetDirectoryName(this.GetType().Assembly.Location);

            var environment = new DefaultNancyEnvironment();

            environment.StaticContent(safepaths: assemblyPath);

            this.context = new NancyContext {
                Environment = environment
            };

            this.imagePath =
                Path.GetFileName(this.GetType().Assembly.Location);
        }
Esempio n. 6
0
        public void Should_use_filename_and_content_type_for_attachments_from_file_response_if_not_overridden()
        {
            // Given
            var assemblyPath =
                Path.GetDirectoryName(this.GetType().Assembly.Location);

            var environment = new DefaultNancyEnvironment();
            environment.StaticContent(safepaths:assemblyPath);

            var filename = Path.GetFileName(this.GetType().Assembly.Location);
            var response = new GenericFileResponse(filename, "image/png", new NancyContext() {Environment = environment});

            // When
            var result = response.AsAttachment();
            
            // Then
            result.Headers["Content-Disposition"].ShouldContain(filename);
            result.ContentType.ShouldEqual("image/png");
        }
        public void Should_use_filename_and_content_type_for_attachments_from_file_response_if_not_overridden()
        {
            // Given
            var environment = new DefaultNancyEnvironment();

            environment.StaticContent(safepaths: this.GetLocation());

            var filename = this.GetFilePath();
            var response = new GenericFileResponse(filename, "foo/bar", new NancyContext()
            {
                Environment = environment
            });

            // When
            var result = response.AsAttachment();

            // Then
            result.Headers["Content-Disposition"].ShouldContain(Path.GetFileName(filename));
            result.ContentType.ShouldEqual("foo/bar");
        }
Esempio n. 8
0
        public void Should_use_filename_and_content_type_for_attachments_from_file_response_if_not_overridden()
        {
            // Given
            var assemblyPath =
                Path.GetDirectoryName(this.GetType().Assembly.Location);

            var environment = new DefaultNancyEnvironment();

            environment.StaticContent(safepaths: assemblyPath);

            var filename = Path.GetFileName(this.GetType().Assembly.Location);
            var response = new GenericFileResponse(filename, "image/png", new NancyContext()
            {
                Environment = environment
            });

            // When
            var result = response.AsAttachment();

            // Then
            result.Headers["Content-Disposition"].ShouldContain(filename);
            result.ContentType.ShouldEqual("image/png");
        }