public void Test_Reading_An_Object()
        {
            string value = "value";

            treeReader(binaryReader, rootNode).Returns(value);

            string result = serializer.Read(binaryReader);

            result.Should()
            .BeSameAs(value);
        }
Example #2
0
        public void Test_Reading_With_A_Null_BinarySerializer_Directly_From_A_Stream()
        {
            IBinarySerializer <string> binarySerializer = null;

            WithDummyStream(stream =>
            {
                Action action = () => binarySerializer.Read(stream);

                action.Should()
                .ThrowArgumentNullException("binarySerializer");
            });
        }
        public void Test_Reading_BKD_File_Successfully(SerializationTestCaseData <BKD> testCaseData)
        {
            using (var stream = new FileStream(testCaseData.TestFilePath, FileMode.Open))
            {
                var reader = Reader.ForStream(stream);

                serializer
                .Read(reader)
                .Should()
                .Be(testCaseData.Expected);
            }
        }
Example #4
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);
            });
        }