public void Given_empty_header_when_parsing_should_return_empty_dictionary() { // Act HttpHeaders actual = HttpHeadersCollection.Parse(string.Empty); // Assert actual.Should().BeEmpty(); }
public void Given_single_invalid_header_string_with_when_parsing_should_throw(string invalidHeaderString, string exceptionMessage) { // Act Action act = () => HttpHeadersCollection.Parse(invalidHeaderString); // Assert act.Should().Throw <Exception>() .WithMessage(exceptionMessage); }
public void Given_null_header_when_parsing_should_throw() { // Act Action act = () => HttpHeadersCollection.Parse(null); // Assert act.Should() .Throw <ArgumentNullException>() .WithParamName("headers"); }
public void Given_multiple_empty_newlines_when_parsing_should_ignore_newlines() { string headers = Environment.NewLine + Environment.NewLine + "Header: Value"; // Act HttpHeaders actual = HttpHeadersCollection.Parse(headers); // Assert actual.Should().HaveCount(1); actual.Should().Contain(h => h.Key == "Header"); }
public void Given_single_header_string_when_parsing_should_return_key_with_one_or_more_values(string headerString, string expectedHeaderKey, params string[] expectedValues) { // Act HttpHeaders headers = HttpHeadersCollection.Parse(headerString); // Assert headers.TryGetValues(expectedHeaderKey, out IEnumerable <string> values) .Should() .BeTrue(); values .Should() .BeEquivalentTo(expectedValues); }