Exemplo n.º 1
0
        public void Test_Reading_With_A_BinarySerializer_Directly_From_A_Stream()
        {
            string expected = nameof(expected);

            WithDummyStream(stream =>
            {
                binarySerializer.Read(Arg.Any <IBinaryReader>()).Returns(expected);

                string result = binarySerializer.Read(stream);

                binarySerializer.Received().Read(Arg.Do <IBinaryReader>(binaryReader =>
                {
                    binaryReader.Should().BeOfType <BinaryReaderWrapper>();

                    typeof(BinaryReaderWrapper)
                    .GetField("realReader", BindingFlags.Instance | BindingFlags.NonPublic)
                    .GetValue(binaryReader)
                    .Should()
                    .BeSameAs(stream);
                }));

                result.Should().Be(expected);
            });
        }