Exemplo n.º 1
0
        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");
        }
Exemplo n.º 2
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);

            GenericFileResponse.SafePaths = new List<string> {assemblyPath};

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

            // When
            var result = response.AsAttachment();
            
            // Then
            result.Headers["Content-Disposition"].ShouldContain(filename);
            result.ContentType.ShouldEqual("image/png");
        }
Exemplo n.º 3
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");
        }
Exemplo n.º 4
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);

            GenericFileResponse.RootPath =
                Path.GetFullPath(Path.Combine(assemblyPath, @"..", @".."));

            var filename = Path.Combine("Resources", "zip.png");
            var response = new GenericFileResponse(filename, "image/png");

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

            // Then
            result.Headers["Content-Disposition"].ShouldContain("zip.png");
            result.ContentType.ShouldEqual("image/png");
        }
        public void Should_use_filename_and_content_type_for_attachments_from_file_response_if_not_overridden()
        {
            var filename = Path.Combine(@"..", @"..", "Resources", "zip.png");
            var response = new GenericFileResponse(filename, "image/png");

            var result = response.AsAttachment();

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