public async Task When_serializing_should_produce_correct_binary_data()
        {
            byte[] fakeControllerData = { 0x20, 0x6c, 0x61, 0x62 };
            byte[] expectedRawData    = new byte[] { 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
            .Concat(fakeControllerData)
            .ToArray();

            _controllerWriterMock
            .Setup(m => m.Write(It.IsAny <Stream>(), It.IsAny <object>()))
            .Callback <Stream, object>((ms, _) => ms.Write(fakeControllerData, 0, fakeControllerData.Length));

            var controller = new object();
            var chunk      = new ControllerDataChunk(
                _controllerReaderMock.Object,
                _controllerWriterMock.Object
                )
            {
                ParentId       = 123,
                ControllerData = controller
            };

            using (var ms = new MemoryStream())
            {
                // Act
                await chunk.SerializeAsync(ms, false);

                // Assert
                ms.ToArray().Should().BeEquivalentTo(expectedRawData);
                _controllerWriterMock.Verify(m => m.Write(ms, controller), Times.Once);
            }
        }
        public ControllerDataChunkTests()
        {
            _controllerReaderMock = new Mock <IControllerReader>();
            _controllerWriterMock = new Mock <IControllerWriter>();

            _sut = new ControllerDataChunk(
                _controllerReaderMock.Object,
                _controllerWriterMock.Object
                );
        }
        public void When_creating_new_instance_should_set_defaults()
        {
            var newInstance = new ControllerDataChunk(
                _controllerReaderMock.Object,
                _controllerWriterMock.Object
                );
            var compareToInstance = new ControllerDataChunk(
                _controllerReaderMock.Object,
                _controllerWriterMock.Object
                )
            {
                ParentFile = null,
                FileOffset = 0,
                Magic      = DatFile.Magics.ControllerData,
                ParentId   = 0,
                SubType    = 0
            };

            // Assert
            newInstance.Should().BeEquivalentTo(compareToInstance);
        }