Beispiel #1
0
        public async Task Given_null_content_when_cloning_should_return_null_content()
        {
            HttpContent content = null;

            // Act
            // ReSharper disable once ExpressionIsAlwaysNull
            ByteArrayContent clone = await content.CloneAsByteArrayContentAsync();

            // Assert
            clone.Should().BeNull();
        }
Beispiel #2
0
        public async Task Given_content_when_cloning_should_return_byte_array_content_with_same_data_and_headers(HttpContent content, string expectedData)
        {
            // Act
            ByteArrayContent clone = await content.CloneAsByteArrayContentAsync();

            // Assert
            clone.Should().NotBeNull();
            clone.Headers.Should().BeEquivalentTo(content.Headers);

            string actual = await clone.ReadAsStringAsync();

            actual.Should().Be(expectedData);
        }
Beispiel #3
0
        public async Task Given_content_when_cloning_multiple_times_should_not_throw(HttpContent content, string expectedData)
        {
            // Act
            for (int i = 0; i < 3; i++)
            {
                ByteArrayContent clone = null;
                Func <Task>      act   = async() => clone = await content.CloneAsByteArrayContentAsync();

                // Assert
                await act.Should().NotThrowAsync();

                clone.Should().NotBeNull();
                clone.Headers.Should().BeEquivalentTo(content.Headers, "iteration {0} should have same headers", i);

                string actual = await clone.ReadAsStringAsync();

                actual.Should().Be(expectedData, "iteration {0} should have same data", i);
            }
        }