public async Task DeserializeAsync_EmptyMessageWithHardcodedType_CustomBinaryFileReturned()
        {
            var headers = new MessageHeaderCollection();

            var serializer = new BinaryFileMessageSerializer <InheritedBinaryFileMessage>();

            var(deserializedObject, type) = await serializer
                                            .DeserializeAsync(new MemoryStream(), headers, MessageSerializationContext.Empty);

            deserializedObject.Should().BeOfType <InheritedBinaryFileMessage>();
            deserializedObject.As <BinaryFileMessage>().Content.ReadAll() !.Length.Should().Be(0);
            type.Should().Be(typeof(InheritedBinaryFileMessage));
        }
        public async Task DeserializeAsync_NullMessageWithHardcodedType_CustomBinaryFileReturned()
        {
            var headers = new MessageHeaderCollection();

            var serializer = new BinaryFileMessageSerializer <InheritedBinaryFileMessage>();

            var(deserializedObject, type) = await serializer
                                            .DeserializeAsync(null, headers, MessageSerializationContext.Empty);

            deserializedObject.Should().BeOfType <InheritedBinaryFileMessage>();
            deserializedObject.Should().BeEquivalentTo(
                new InheritedBinaryFileMessage
            {
                Content = null
            });
            type.Should().Be(typeof(InheritedBinaryFileMessage));
        }
        public async Task DeserializeAsync_WithHardcodedType_CustomBinaryFileReturned()
        {
            var rawContent = new MemoryStream(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 });
            var headers    = new MessageHeaderCollection();

            var serializer = new BinaryFileMessageSerializer <InheritedBinaryFileMessage>();

            var(deserializedObject, type) = await serializer
                                            .DeserializeAsync(rawContent, headers, MessageSerializationContext.Empty);

            deserializedObject.Should().BeOfType <InheritedBinaryFileMessage>();
            deserializedObject.Should().BeEquivalentTo(
                new InheritedBinaryFileMessage
            {
                Content = rawContent
            });
            type.Should().Be(typeof(InheritedBinaryFileMessage));
        }
        public async Task SerializeDeserializeAsync_HardcodedType_CorrectlyDeserialized()
        {
            var message = new InheritedBinaryFileMessage
            {
                Content = new MemoryStream(new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05 })
            };
            var headers = new MessageHeaderCollection();

            var serializer = new BinaryFileMessageSerializer <InheritedBinaryFileMessage>();
            var serialized = await serializer.SerializeAsync(message, headers, MessageSerializationContext.Empty);

            var(deserialized, _) = await serializer
                                   .DeserializeAsync(serialized, headers, MessageSerializationContext.Empty);

            var message2 = deserialized as BinaryFileMessage;

            message2.Should().NotBeNull();
            message2.Should().BeEquivalentTo(message);
        }