Exemplo n.º 1
0
        public void Test_Edges_Should_Be_Empty <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node = new PrimitiveTypeDataNode <T>();

            node.Edges.Should().BeEmpty();
        }
Exemplo n.º 2
0
        public void Test_Writing_With_A_Null_BinaryWriter <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node   = new PrimitiveTypeDataNode <T>();
            Action    action = () => node.Write(null, testCaseData.Value);

            action.Should()
            .ThrowArgumentNullException("binaryWriter");
        }
Exemplo n.º 3
0
        public void Test_Writing_A_Primitive <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node = new PrimitiveTypeDataNode <T>();

            node.Write(binaryWriter, testCaseData.Value);

            testCaseData.VerifyWrite(binaryWriter);
        }
Exemplo n.º 4
0
        public void Test_Reading_A_Primitive_From_A_Null_Reader <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node   = new PrimitiveTypeDataNode <T>();
            Action    action = () => node.Read(null);

            action.Should()
            .ThrowArgumentNullException("binaryReader");
        }
Exemplo n.º 5
0
        public void Test_Writing_With_Value_Of_The_Incorrect_Type <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node   = new PrimitiveTypeDataNode <T>();
            object    value  = new object();
            Action    action = () => node.Write(binaryWriter, value);

            action.Should()
            .ThrowExactly <ArgumentException>()
            .WithMessage($"Cannot write value of type {value.GetType().Name} as type {typeof(T).Name}.");
        }
Exemplo n.º 6
0
        public void Test_Reading_A_Primitive <T>(PrimitiveTypeTestCaseData <T> testCaseData)
            where T : struct
        {
            IDataNode node = new PrimitiveTypeDataNode <T>();

            testCaseData.SetupRead(binaryReader);

            object result = node.Read(binaryReader);

            result.Should()
            .BeOfType(typeof(T))
            .And
            .Be(testCaseData.Value);
        }