Ejemplo n.º 1
0
        public void Should_extract_empty_value_from_boundary_when_not_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                "text/plain",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            GetValueAsString(boundary.Value).ShouldBeEmpty();
        }
Ejemplo n.º 2
0
        public void Should_extract_value_from_boundary_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                "text/plain",
                "This is some contents"
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            GetValueAsString(boundary.Value).ShouldEqual("This is some contents");
        }
Ejemplo n.º 3
0
        public void Should_handle_non_ASCII_filenames()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "file_content",
                "Данные.txt",
                "application/octet-stream",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("Данные.txt");
        }
Ejemplo n.º 4
0
        public void Should_extract_content_type_from_boundary_headers_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                null,
                "text/plain",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.ContentType.ShouldEqual("text/plain");
        }
        public void Should_extract_file_name_from_boundary_headers_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("sample.txt");
        }
Ejemplo n.º 6
0
        public void Should_extract_name_from_boundary_headers()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                null,
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Name.ShouldEqual("name");
        }
        public void Should_handle_non_ASCII_filenames()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "file_content",
                "Данные.txt",
                "application/octet-stream",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("Данные.txt");
        }
        public void Should_set_file_name_to_empty_when_it_could_not_be_found_in_header()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                null,
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldBeEmpty();
        }
        public void Should_extract_name_from_boundary_headers()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name", 
                null,
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Name.ShouldEqual("name");
        }
Ejemplo n.º 10
0
        public void Should_extract_file_name_from_boundary_headers_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("sample.txt");
        }
Ejemplo n.º 11
0
        public void Should_set_file_name_to_empty_when_it_could_not_be_found_in_header()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                null,
                null,
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldBeEmpty();
        }
Ejemplo n.º 12
0
        public void Should_handle_utf_8_filenamestar_param()
        {
            // Given
            var contentDispositionHeader = BuildContentDispositionHeader(
                "file_content",
                "utf-8''file_%C3%A9%C3%A0%C3%A2%C3%A8%C3%A9%C3%A7.txt");
            var stream = BuildStreamForSingleFile(
                contentDispositionHeader,
                "application/octet-stream",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("file_éàâèéç.txt");
        }
Ejemplo n.º 13
0
        public void Should_handle_utf_8_filenamestar_param()
        {
            // Given
            var contentDispositionHeader = BuildContentDispositionHeader(
            "file_content",
            "utf-8''file_%C3%A9%C3%A0%C3%A2%C3%A8%C3%A9%C3%A7.txt");
            var stream = BuildStreamForSingleFile(
            contentDispositionHeader,
            "application/octet-stream",
            null
            );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("file_éàâèéç.txt");

        }
Ejemplo n.º 14
0
        public void Should_handle_presence_of_filenamestar_param_in_content_disposition_header()
        {
            // Given
            var contentDispositionHeader = BuildContentDispositionHeader(
                "file_content",
                "sample.txt",
                "utf-8''foo-%c3%a4.html",
                unquotedFilenameValue: true
                );

            var stream = BuildStreamForSingleFile(
                contentDispositionHeader,
                "application/octet-stream",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("sample.txt");
        }
Ejemplo n.º 15
0
        public void Should_handle_presence_of_filenamestar_param_in_content_disposition_header()
        {
            // Given
            var contentDispositionHeader = BuildContentDispositionHeader(
                "file_content",
                "sample.txt",
                "utf-8''foo-%c3%a4.html",
                unquotedFilenameValue: true
                );

            var stream = BuildStreamForSingleFile(
                contentDispositionHeader,
                "application/octet-stream",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.Filename.ShouldEqual("sample.txt");
        }
        public void Should_extract_empty_value_from_boundary_when_not_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                "text/plain",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            GetValueAsString(boundary.Value).ShouldBeEmpty();
        }
        public void Should_extract_value_from_boundary_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                "sample.txt",
                "text/plain",
                "This is some contents"
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            GetValueAsString(boundary.Value).ShouldEqual("This is some contents");
        }
        public void Should_extract_content_type_from_boundary_headers_when_available()
        {
            // Given
            var stream = BuildStreamForSingleFile(
                "name",
                null,
                "text/plain",
                null
                );

            // When
            var boundary = new HttpMultipartBoundary(stream);

            // Then
            boundary.ContentType.ShouldEqual("text/plain");
        }