private void AssertCorrectness(string[] headers, string[] expected) { var segments = new HeaderSegmentCollection(headers); var strings = segments.SelectMany(seg => new[] { seg.Formatting.Value, seg.Data.Value }).ToArray(); strings.ShouldBe(expected); }
public void QuotedCommasArePartOfValue() { var segments = new HeaderSegmentCollection(new[] { "\" value , yep \"" }).ToArray(); segments.Count().ShouldBe(1); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("\" value , yep \""); }
public void CommasSplitUp() { var segments = new HeaderSegmentCollection(new[] { " \r\n \t value, yep" }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(" \r\n \t "); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(", "); segments[1].Data.Value.ShouldBe("yep"); }
public void TrailingWhitespaceCausesFormattingSegmentWithNoData() { var segments = new HeaderSegmentCollection(new[] { "x " }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("x"); segments[1].Formatting.Value.ShouldBe(" "); segments[1].Data.Value.ShouldBe(null); }
public void WhitespaceAddedToNextFormatting() { var segments = new HeaderSegmentCollection(new[] { "value , yep" }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(" , "); segments[1].Data.Value.ShouldBe("yep"); }
public void CommasSplitUp() { var segments = new HeaderSegmentCollection(new[] { " \r\n \t value, yep" }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(" \r\n \t "); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(", "); segments[1].Data.Value.ShouldBe("yep"); }
public void TailingWhitespaceHasThatEffectOn() { var segments = new HeaderSegmentCollection(new[] { " value , yep " }).ToArray(); segments.Count().ShouldBe(3); segments[0].Formatting.Value.ShouldBe(" "); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(" , "); segments[1].Data.Value.ShouldBe("yep"); segments[2].Formatting.Value.ShouldBe(" "); segments[2].Data.Value.ShouldBe(null); }
private StringSegment SingleSegment(OwinResponse response, string header) { HeaderSegmentCollection.Enumerator cursor = new HeaderSegmentCollection(response.GetHeaderUnmodified(header)).GetEnumerator(); if (cursor.MoveNext()) { HeaderSegment segment = cursor.Current; if (cursor.MoveNext() == false) { return(segment.Data); } } return(new StringSegment()); }
private void AssertCorrectness(string[] headers, string[] expected) { var segments = new HeaderSegmentCollection(headers); var strings = segments.SelectMany(seg => new[] { seg.Formatting.Value, seg.Data.Value }).ToArray(); strings.ShouldBe(expected); }
public void WhitespaceAddedToNextFormatting() { var segments = new HeaderSegmentCollection(new[] { "value , yep" }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(" , "); segments[1].Data.Value.ShouldBe("yep"); }
public void TrailingWhitespaceCausesFormattingSegmentWithNoData() { var segments = new HeaderSegmentCollection(new[] { "x " }).ToArray(); segments.Count().ShouldBe(2); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("x"); segments[1].Formatting.Value.ShouldBe(" "); segments[1].Data.Value.ShouldBe(null); }
public void TailingWhitespaceHasThatEffectOn() { var segments = new HeaderSegmentCollection(new[] { " value , yep " }).ToArray(); segments.Count().ShouldBe(3); segments[0].Formatting.Value.ShouldBe(" "); segments[0].Data.Value.ShouldBe("value"); segments[1].Formatting.Value.ShouldBe(" , "); segments[1].Data.Value.ShouldBe("yep"); segments[2].Formatting.Value.ShouldBe(" "); segments[2].Data.Value.ShouldBe(null); }
public void QuotedCommasArePartOfValue() { var segments = new HeaderSegmentCollection(new[] { "\" value , yep \"" }).ToArray(); segments.Count().ShouldBe(1); segments[0].Formatting.Value.ShouldBe(string.Empty); segments[0].Data.Value.ShouldBe("\" value , yep \""); }
private StringSegment SingleSegment(OwinResponse response, string header) { HeaderSegmentCollection.Enumerator cursor = new HeaderSegmentCollection(response.GetHeaderUnmodified(header)).GetEnumerator(); if (cursor.MoveNext()) { HeaderSegment segment = cursor.Current; if (cursor.MoveNext() == false) { return segment.Data; } } return new StringSegment(); }
public bool Equals(HeaderSegmentCollection other) { return(StringValues.Equals(_headers, other._headers)); }