예제 #1
0
        public virtual void TestLessThan()
        {
            var MessageId1 = new MessageId(124L, 345L, 567);
            var MessageId2 = new MessageId(123L, 345L, 567);
            var MessageId3 = new MessageId(123L, 344L, 567);
            var MessageId4 = new MessageId(123L, 344L, 566);

            var batchMessageId1 = new BatchMessageId(235L, 345L, 456, 567);
            var batchMessageId2 = new BatchMessageId(234L, 346L, 456, 567);
            var batchMessageId3 = new BatchMessageId(234L, 345L, 456, 568);
            var batchMessageId4 = new BatchMessageId(234L, 345L, 457, 567);
            var batchMessageId5 = new BatchMessageId(234L, 345L, 456, 567);

            Assert.True(MessageId2.CompareTo(MessageId1) < 0, "Expected to be less than");
            Assert.True(MessageId3.CompareTo(MessageId1) < 0, "Expected to be less than");
            Assert.True(MessageId4.CompareTo(MessageId1) < 0, "Expected to be less than");
            Assert.True(MessageId3.CompareTo(MessageId2) < 0, "Expected to be less than");
            Assert.True(MessageId4.CompareTo(MessageId2) < 0, "Expected to be less than");
            Assert.True(MessageId4.CompareTo(MessageId3) < 0, "Expected to be less than");

            Assert.True(batchMessageId2.CompareTo(batchMessageId1) < 0, "Expected to be less than");
            Assert.True(batchMessageId3.CompareTo(batchMessageId1) < 0, "Expected to be less than");
            Assert.True(batchMessageId4.CompareTo(batchMessageId1) < 0, "Expected to be less than");
            Assert.True(batchMessageId5.CompareTo(batchMessageId1) < 0, "Expected to be less than");
            Assert.True(batchMessageId3.CompareTo(batchMessageId2) < 0, "Expected to be less than");
            Assert.True(batchMessageId4.CompareTo(batchMessageId2) < 0, "Expected to be less than");
            Assert.True(batchMessageId5.CompareTo(batchMessageId2) < 0, "Expected to be less than");
            Assert.True(batchMessageId4.CompareTo(batchMessageId3) < 0, "Expected to be less than");
            Assert.True(batchMessageId5.CompareTo(batchMessageId3) < 0, "Expected to be less than");
            Assert.True(batchMessageId5.CompareTo(batchMessageId4) < 0, "Expected to be less than");
        }
예제 #2
0
        public void CompareToTest()
        {
            var batchMsgId1 = new BatchMessageId(0, 0, 0, 0);
            var batchMsgId2 = new BatchMessageId(1, 1, 1, 1);

            Assert.Equal(-1, batchMsgId1.CompareTo(batchMsgId2));
            Assert.Equal(1, batchMsgId2.CompareTo(batchMsgId1));
            Assert.Equal(0, batchMsgId2.CompareTo(batchMsgId2));
        }
예제 #3
0
        public virtual void TestBatchMessageIdCompareToTopicMessageId()
        {
            var MessageId1      = new BatchMessageId(123L, 345L, 567, 789);
            var MessageId2      = new BatchMessageId(123L, 345L, 567, 0);
            var MessageId3      = new BatchMessageId(123L, 345L, 567, -1);
            var topicMessageId1 = new TopicMessageId("test-topic-partition-0", "test-topic", new MessageId(123L, 345L, 566));
            var topicMessageId2 = new TopicMessageId("test-topic-partition-0", "test-topic", new MessageId(123L, 345L, 567));

            Assert.True(MessageId1.CompareTo(topicMessageId1) > 0, "Expected to be greater than");
            Assert.True(MessageId1.CompareTo(topicMessageId2) > 0, "Expected to be greater than");
            Assert.True(MessageId2.CompareTo(topicMessageId2) > 0, "Expected to be greater than");
            Assert.Equal(0, MessageId3.CompareTo(topicMessageId2));
            Assert.True(topicMessageId1.CompareTo(MessageId1) < 0, "Expected to be less than");
            Assert.True(topicMessageId2.CompareTo(MessageId1) < 0, "Expected to be less than");
            Assert.True(topicMessageId2.CompareTo(MessageId2) < 0, "Expected to be less than");
            Assert.True(topicMessageId2.CompareTo(MessageId2) < 0, "Expected to be less than");
        }
예제 #4
0
        public virtual void TestEqual()
        {
            var MessageId1 = new MessageId(123L, 345L, 567);
            var MessageId2 = new MessageId(123L, 345L, 567);

            var batchMessageId1 = new BatchMessageId(234L, 345L, 456, 567);
            var batchMessageId2 = new BatchMessageId(234L, 345L, 456, 567);

            Assert.Equal(0, MessageId1.CompareTo(MessageId2));
            Assert.Equal(0, batchMessageId1.CompareTo(batchMessageId2));
        }
예제 #5
0
        public virtual void TestCompareDifferentType()
        {
            var MessageId       = new MessageId(123L, 345L, 567);
            var batchMessageId1 = new BatchMessageId(123L, 345L, 566, 789);
            var batchMessageId2 = new BatchMessageId(123L, 345L, 567, 789);
            var batchMessageId3 = new BatchMessageId(MessageId);

            Assert.True(MessageId.CompareTo(batchMessageId1) > 0, "Expected to be greater than");
            Assert.True(MessageId.CompareTo(batchMessageId2) < 0, "Expected to be less than");
            Assert.Equal(0, MessageId.CompareTo(batchMessageId3));
            Assert.True(batchMessageId1.CompareTo(MessageId) < 0, "Expected to be less than");
            Assert.True(batchMessageId2.CompareTo(MessageId) > 0, "Expected to be greater than");
            Assert.Equal(0, batchMessageId3.CompareTo(MessageId));
        }
예제 #6
0
        public virtual void CompareToSymmetricTest()
        {
            var simpleMessageId = new MessageId(123L, 345L, 567);
            // batchIndex is -1 if message is non-batched message and has the batchIndex for a batch message
            var batchMessageId1 = new BatchMessageId(123L, 345L, 567, -1);
            var batchMessageId2 = new BatchMessageId(123L, 345L, 567, 1);
            var batchMessageId3 = new BatchMessageId(123L, 345L, 566, 1);
            var batchMessageId4 = new BatchMessageId(123L, 345L, 566, -1);

            Assert.Equal(0, simpleMessageId.CompareTo(batchMessageId1));
            Assert.Equal(0, batchMessageId1.CompareTo(simpleMessageId));
            Assert.True(batchMessageId2.CompareTo(simpleMessageId) > 0, "Expected to be greater than");
            Assert.True(simpleMessageId.CompareTo(batchMessageId2) < 0, "Expected to be less than");
            Assert.True(simpleMessageId.CompareTo(batchMessageId3) > 0, "Expected to be greater than");
            Assert.True(batchMessageId3.CompareTo(simpleMessageId) < 0, "Expected to be less than");
            Assert.True(simpleMessageId.CompareTo(batchMessageId4) > 0, "Expected to be greater than");
            Assert.True(batchMessageId4.CompareTo(simpleMessageId) < 0, "Expected to be less than");
        }