public void IteratorSetValueShouldChangeHeaderValue() { TestDefaultHeaders headers = NewInstance(); headers.Add(Of("name1"), new[] { Of("value1"), Of("value2"), Of("value3") }); headers.Add(Of("name2"), Of("value4")); Assert.Equal(4, headers.Size); foreach (HeaderEntry <ICharSequence, ICharSequence> header in headers) { if (Of("name1").Equals(header.Key) && Of("value2").Equals(header.Value)) { header.SetValue(Of("updatedvalue2")); Assert.Equal(Of("updatedvalue2"), header.Value); } if (Of("name1").Equals(header.Key) && Of("value3").Equals(header.Value)) { header.SetValue(Of("updatedvalue3")); Assert.Equal(Of("updatedvalue3"), header.Value); } } Assert.Equal(4, headers.Size); Assert.True(headers.Contains(Of("name1"), Of("updatedvalue2"))); Assert.False(headers.Contains(Of("name1"), Of("value2"))); Assert.True(headers.Contains(Of("name1"), Of("updatedvalue3"))); Assert.False(headers.Contains(Of("name1"), Of("value3"))); }
public void AfterClearHeadersShouldBeEmpty() { TestDefaultHeaders headers = NewInstance(); headers.Add(Of("name1"), Of("value1")); headers.Add(Of("name2"), Of("value2")); Assert.Equal(2, headers.Size); headers.Clear(); Assert.Equal(0, headers.Size); Assert.True(headers.IsEmpty); Assert.False(headers.Contains(Of("name1"))); Assert.False(headers.Contains(Of("name2"))); }
public void Contains() { TestDefaultHeaders headers = NewInstance(); headers.AddBoolean(Of("boolean"), true); Assert.True(headers.ContainsBoolean(Of("boolean"), true)); Assert.False(headers.ContainsBoolean(Of("boolean"), false)); headers.AddLong(Of("long"), long.MaxValue); Assert.True(headers.ContainsLong(Of("long"), long.MaxValue)); Assert.False(headers.ContainsLong(Of("long"), long.MinValue)); headers.AddInt(Of("int"), int.MinValue); Assert.True(headers.ContainsInt(Of("int"), int.MinValue)); Assert.False(headers.ContainsInt(Of("int"), int.MaxValue)); headers.AddShort(Of("short"), short.MaxValue); Assert.True(headers.ContainsShort(Of("short"), short.MaxValue)); Assert.False(headers.ContainsShort(Of("short"), short.MinValue)); headers.AddChar(Of("char"), char.MaxValue); Assert.True(headers.ContainsChar(Of("char"), char.MaxValue)); Assert.False(headers.ContainsChar(Of("char"), char.MinValue)); headers.AddByte(Of("byte"), byte.MaxValue); Assert.True(headers.ContainsByte(Of("byte"), byte.MaxValue)); Assert.False(headers.ContainsByte(Of("byte"), byte.MinValue)); headers.AddDouble(Of("double"), double.MaxValue); Assert.True(headers.ContainsDouble(Of("double"), double.MaxValue)); Assert.False(headers.ContainsDouble(Of("double"), double.MinValue)); headers.AddFloat(Of("float"), float.MaxValue); Assert.True(headers.ContainsFloat(Of("float"), float.MaxValue)); Assert.False(headers.ContainsFloat(Of("float"), float.MinValue)); long millis = (long)Math.Floor(DateTime.UtcNow.Ticks / (double)TimeSpan.TicksPerMillisecond); headers.AddTimeMillis(Of("millis"), millis); Assert.True(headers.ContainsTimeMillis(Of("millis"), millis)); // This test doesn't work on midnight, January 1, 1970 UTC Assert.False(headers.ContainsTimeMillis(Of("millis"), 0)); headers.AddObject(Of("object"), "Hello World"); Assert.True(headers.ContainsObject(Of("object"), "Hello World")); Assert.False(headers.ContainsObject(Of("object"), "")); headers.Add(Of("name"), Of("value")); Assert.True(headers.Contains(Of("name"), Of("value"))); Assert.False(headers.Contains(Of("name"), Of("value1"))); }
public void CanMixConvertedAndNormalValues() { TestDefaultHeaders headers = NewInstance(); headers.Add(Of("name"), Of("value")); headers.AddInt(Of("name"), 100); headers.AddBoolean(Of("name"), false); Assert.Equal(3, headers.Size); Assert.True(headers.Contains(Of("name"))); Assert.True(headers.Contains(Of("name"), Of("value"))); Assert.True(headers.ContainsInt(Of("name"), 100)); Assert.True(headers.ContainsBoolean(Of("name"), false)); }