Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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));
        }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        public void When_Created_As_ReadOnly_Is_ReadOnly()
        {
            var headers = new KafkaEventDataHeaders(true);

            Assert.True(headers.IsReadOnly);
            Assert.Throws <NotSupportedException>(() => headers.Add("test", null));
        }
Beispiel #6
0
        public void GetFirst_Throws_On_InvalidKey()
        {
            var headers = new KafkaEventDataHeaders();

            headers.Add("test", Encoding.UTF8.GetBytes("testValue1"));

            Assert.Throws <KeyNotFoundException>(() => headers.GetFirst("test2"));
        }
Beispiel #7
0
        public void Add_Throws_When_Key_Is_Null()
        {
            var headers = new KafkaEventDataHeaders();

            Assert.Throws <ArgumentNullException>(() => headers.Add(null, null));
        }