Beispiel #1
0
        public void JoinConsumerGroupResponse(
            [Values(
                 ErrorResponseCode.None,
                 ErrorResponseCode.OffsetMetadataTooLarge
                 )] ErrorResponseCode errorCode,
            [Values(0, 1, 20000)] int generationId,
            [Values("consumer")] string protocol,
            [Values("test", "a groupId")] string leaderId,
            [Values("", "an existing member")] string memberId,
            [Values(1, 10)] int memberCount)
        {
            var encoder = new ConsumerEncoder();
            var members = new List <JoinGroupResponse.Member>();

            for (var m = 0; m < memberCount; m++)
            {
                var userData = new byte[memberCount * 100];
                _randomizer.NextBytes(userData);
                var metadata = new ConsumerProtocolMetadata(0, new [] { protocol, memberId, leaderId }, userData);
                members.Add(new JoinGroupResponse.Member(memberId + m, metadata));
            }
            var response = new JoinGroupResponse(errorCode, generationId, protocol, leaderId, memberId, members);

            response.AssertCanEncodeDecodeResponse(0, encoder);
        }
        public void JoinGroupResponse(
            [Values(
                 ErrorCode.NONE,
                 ErrorCode.OFFSET_METADATA_TOO_LARGE
                 )] ErrorCode errorCode,
            [Values(0, 1, 20000)] int generationId,
            [Values("consumer", "other")] string protocol,
            [Values("test", "a groupId")] string leaderId,
            [Values("", "an existing member")] string memberId,
            [Values(1, 10)] int memberCount)
        {
            var members = new List <JoinGroupResponse.Member>();

            for (var m = 0; m < memberCount; m++)
            {
                var bytes = new byte[memberCount * 100];
                _randomizer.NextBytes(bytes);
                members.Add(new JoinGroupResponse.Member(memberId + m, new ByteTypeMetadata("known", new ArraySegment <byte>(bytes))));
            }
            var response = new JoinGroupResponse(errorCode, generationId, "known", leaderId, memberId, members);

            response.AssertCanEncodeDecodeResponse(0, new ByteMembershipEncoder(protocol));
        }