public void SetAllShouldOverwriteSomeAndLeaveOthersUntouched() { TestDefaultHeaders h1 = NewInstance(); h1.Add(Of("name1"), Of("value1")); h1.Add(Of("name2"), Of("value2")); h1.Add(Of("name2"), Of("value3")); h1.Add(Of("name3"), Of("value4")); TestDefaultHeaders h2 = NewInstance(); h2.Add(Of("name1"), Of("value5")); h2.Add(Of("name2"), Of("value6")); h2.Add(Of("name1"), Of("value7")); TestDefaultHeaders expected = NewInstance(); expected.Add(Of("name1"), Of("value5")); expected.Add(Of("name2"), Of("value6")); expected.Add(Of("name1"), Of("value7")); expected.Add(Of("name3"), Of("value4")); h1.SetAll(h2); Assert.True(expected.Equals(h1)); }
public void EmptyHeadersShouldBeEqual() { TestDefaultHeaders headers1 = NewInstance(); TestDefaultHeaders headers2 = NewInstance(); Assert.NotSame(headers1, headers2); Assert.True(headers1.Equals(headers2)); Assert.Equal(headers1.GetHashCode(), headers2.GetHashCode()); }
public void HeadersWithSameNamesButDifferentValuesShouldNotBeEquivalent() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name1"), Of("value1")); TestDefaultHeaders headers2 = NewInstance(); headers1.Add(Of("name1"), Of("value2")); Assert.False(headers1.Equals(headers2)); }
public void HeadersWithDifferentNamesAndValuesShouldNotBeEquivalent() { TestDefaultHeaders h1 = NewInstance(); h1.Set(Of("name1"), Of("value1")); TestDefaultHeaders h2 = NewInstance(); h2.Set(Of("name2"), Of("value2")); Assert.False(h1.Equals(h2)); Assert.False(h2.Equals(h1)); }
public void SubsetOfHeadersShouldNotBeEquivalent() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name1"), Of("value1")); headers1.Add(Of("name2"), Of("value2")); TestDefaultHeaders headers2 = NewInstance(); headers1.Add(Of("name1"), Of("value1")); Assert.False(headers1.Equals(headers2)); }
public void SetHeadersShouldClearAndOverwrite() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name"), Of("value")); TestDefaultHeaders headers2 = NewInstance(); headers2.Add(Of("name"), Of("newvalue")); headers2.Add(Of("name1"), Of("value1")); headers1.Set(headers2); Assert.True(headers1.Equals(headers2)); }
public void IteratorShouldReturnAllNameValuePairs() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name1"), new[] { Of("value1"), Of("value2") }); headers1.Add(Of("name2"), Of("value3")); headers1.Add(Of("name3"), new[] { Of("value4"), Of("value5"), Of("value6") }); headers1.Add(Of("name1"), new[] { Of("value7"), Of("value8") }); Assert.Equal(8, headers1.Size); TestDefaultHeaders headers2 = NewInstance(); foreach (HeaderEntry <ICharSequence, ICharSequence> entry in headers1) { headers2.Add(entry.Key, entry.Value); } Assert.True(headers1.Equals(headers2)); }
public void HeadersWithSameNamesAndValuesShouldBeEquivalent() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name1"), Of("value1")); headers1.Add(Of("name2"), Of("value2")); headers1.Add(Of("name2"), Of("value3")); TestDefaultHeaders headers2 = NewInstance(); headers2.Add(Of("name1"), Of("value1")); headers2.Add(Of("name2"), Of("value2")); headers2.Add(Of("name2"), Of("value3")); Assert.True(headers1.Equals(headers2)); Assert.True(headers2.Equals(headers1)); Assert.Equal(headers1.GetHashCode(), headers2.GetHashCode()); Assert.Equal(headers1.GetHashCode(), headers1.GetHashCode()); Assert.Equal(headers2.GetHashCode(), headers2.GetHashCode()); }
public void SetAllHeadersShouldOnlyOverwriteHeaders() { TestDefaultHeaders headers1 = NewInstance(); headers1.Add(Of("name"), Of("value")); headers1.Add(Of("name1"), Of("value1")); TestDefaultHeaders headers2 = NewInstance(); headers2.Add(Of("name"), Of("newvalue")); headers2.Add(Of("name2"), Of("value2")); TestDefaultHeaders expected = NewInstance(); expected.Add(Of("name"), Of("newvalue")); expected.Add(Of("name1"), Of("value1")); expected.Add(Of("name2"), Of("value2")); headers1.SetAll(headers2); Assert.True(headers1.Equals(expected)); }