public async Task DeserializeMessageAsync_WithMultipleDeserializers_ShouldPickTheFirstReturnNonNull()
        {
            FooMessage message;

            var node = new TestRemoteNode(
                new IMessageSerializer[]
            {
                new BazSerializer(),
                new FooSerializer(),
                new BarSerializer()
            },
                Enumerable.Empty <IMessageProcessor>()
                );

            using (var payload = FooSerializer.CreateFooPayload(3))
            {
                message = (FooMessage)await node.DeserializeMessageAsync(
                    FooMessage.Id,
                    FooMessage.Size,
                    payload,
                    CancellationToken.None);
            }

            Assert.Equal(3, message.Value1);
        }
        public void DeserializeMessageAsync_PassInvalidPayload_ShouldThrow()
        {
            var node = new TestRemoteNode(
                new[] { new FooSerializer() },
                Enumerable.Empty <IMessageProcessor>()
                );

            using (var payload = FooSerializer.CreateFooPayload(-1))
            {
                Assert.ThrowsAnyAsync <InvalidMessageException>(() =>
                {
                    return(node.DeserializeMessageAsync(
                               FooMessage.Id,
                               FooMessage.Size,
                               payload,
                               CancellationToken.None));
                });
            }
        }
        public async Task DeserializeMessageAsync_PassSupportedMessage_ShouldReturnDeserializedMessage()
        {
            FooMessage message;

            var node = new TestRemoteNode(
                new[] { new FooSerializer() },
                Enumerable.Empty <IMessageProcessor>()
                );

            using (var payload = FooSerializer.CreateFooPayload(5))
            {
                message = (FooMessage)await node.DeserializeMessageAsync(
                    FooMessage.Id,
                    FooMessage.Size,
                    payload,
                    CancellationToken.None);
            }

            Assert.Equal(5, message.Value1);
        }