Exemplo n.º 1
0
        private static void TestCommonResponse <TPartitionResponse>(ReusableMemoryStream serialized, object extra,
                                                                    CommonResponse <TPartitionResponse> expected, Func <TPartitionResponse, TPartitionResponse, bool> comparer)
            where TPartitionResponse : IMemoryStreamSerializable, new()
        {
            serialized.Position = 0;
            var response = CommonResponse <TPartitionResponse> .Deserialize(serialized, extra);

            Assert.AreEqual(expected.TopicsResponse.Length, response.TopicsResponse.Length);
            foreach (var ztr in expected.TopicsResponse.Zip(response.TopicsResponse, Tuple.Create))
            {
                Assert.AreEqual(ztr.Item1.TopicName, ztr.Item2.TopicName);
                Assert.AreEqual(ztr.Item1.PartitionsData.Count(), ztr.Item2.PartitionsData.Count());
                foreach (var zpr in ztr.Item1.PartitionsData.Zip(ztr.Item2.PartitionsData, Tuple.Create))
                {
                    Assert.IsTrue(comparer(zpr.Item1, zpr.Item2));
                }
            }
        }