public void Can_Be_Enumerated() { var headers = new KafkaEventDataHeaders(); headers.Add("test", Encoding.UTF8.GetBytes("testValue1")); headers.Add("test", Encoding.UTF8.GetBytes("testValue1")); Assert.Collection(headers, x => Assert.Equal("test", x.Key), x => Assert.Equal("test", x.Key)); }
public void Remove_Removes_Header() { var headers = new KafkaEventDataHeaders(); headers.Add("test", Encoding.UTF8.GetBytes("test")); headers.Add("test2", Encoding.UTF8.GetBytes("test")); headers.Remove("test2"); Assert.Equal(1, headers.Count); }
public void GetFirst_Returns_The_Last_Header_Value() { var headers = new KafkaEventDataHeaders(); headers.Add("test", Encoding.UTF8.GetBytes("testValue1")); headers.Add("test", Encoding.UTF8.GetBytes("testValue2")); var value = headers.GetFirst("test"); Assert.Equal("testValue1", Encoding.UTF8.GetString(value)); }
public void TryGetFirst_Outputs_The_Last_Header_Value(string key, bool expectedSuccess, string output) { var headers = new KafkaEventDataHeaders(); headers.Add("test", Encoding.UTF8.GetBytes("testValue1")); headers.Add("test", Encoding.UTF8.GetBytes("testValue2")); var success = headers.TryGetFirst(key, out var value); Assert.Equal(expectedSuccess, success); Assert.Equal(output, value == null ? null : Encoding.UTF8.GetString(value)); }
public void When_Created_As_ReadOnly_Is_ReadOnly() { var headers = new KafkaEventDataHeaders(true); Assert.True(headers.IsReadOnly); Assert.Throws <NotSupportedException>(() => headers.Add("test", null)); }
public void GetFirst_Throws_On_InvalidKey() { var headers = new KafkaEventDataHeaders(); headers.Add("test", Encoding.UTF8.GetBytes("testValue1")); Assert.Throws <KeyNotFoundException>(() => headers.GetFirst("test2")); }
public void Add_Throws_When_Key_Is_Null() { var headers = new KafkaEventDataHeaders(); Assert.Throws <ArgumentNullException>(() => headers.Add(null, null)); }