示例#1
0
        public void Test_Building_A_Tree_For_A_Null_Type()
        {
            Action action = () => TreeBuilder.BuildTreeForType(null);

            action.Should()
            .ThrowArgumentNullException("type");
        }
示例#2
0
        private static void BadTypeExceptionShouldBeThrownForType <T>(string message)
        {
            Action action = () => TreeBuilder.BuildTreeForType(typeof(T));

            action.Should()
            .ThrowExactly <BadTypeException>()
            .WithMessage(message)
            .Where(e => typeof(T) == e.Type);
        }
示例#3
0
 /// <summary>
 /// Builds a binary serializer for type <typeparamref name="T"/>.
 /// </summary>
 ///
 /// <typeparam name="T">The type for the binary serializer.</typeparam>
 ///
 /// <returns>A binary serializer for type <typeparamref name="T"/>.</returns>
 public static IBinarySerializer <T> ForType <T>()
 {
     return(new TreeBinarySerializer <T>(
                treeReader: treeReader.Read,
                treeWriter: WriteTree,
                rootNode: TreeBuilder.BuildTreeForType(typeof(T)),
                footerAligner: AlignFooter
                ));
 }
示例#4
0
        public void Test_Building_A_Tree_For_A_Class_With_A_List_With_Duplicated_Entry_Count()
        {
            IDataNode rootNode = TreeBuilder.BuildTreeForType(typeof(ClassWithAListWithDuplicatedEntryCount));

            VerifyTreeForClassWithAList(
                dataNode: rootNode,
                expected: new ClassWithAListWithDuplicatedEntryCount
            {
                Values = new List <ClassWithPrimitiveProperties>()
            },
                extractor: v => v.Values,
                duplicateEntryCount: true
                );
        }
示例#5
0
        public void Test_Building_A_Tree_For_A_Class_With_Nested_Class_With_Primitive_Properties()
        {
            IDataNode rootNode = TreeBuilder.BuildTreeForType(typeof(ClassWithNestedClassWithPrimitiveProperties));

            ClassWithNestedClassWithPrimitiveProperties.BuildSample().VerifyTree(rootNode);
        }
示例#6
0
        public void Test_Building_A_Tree_For_A_Class_With_A_String_Inline()
        {
            IDataNode rootNode = TreeBuilder.BuildTreeForType(typeof(ClassWithStringInline));

            ClassWithStringInline.BuildSample().VerifyTree(rootNode);
        }
示例#7
0
        public void Test_Building_A_Tree_For_A_Class_With_A_String_At_Offset()
        {
            IDataNode rootNode = TreeBuilder.BuildTreeForType(typeof(ClassWithStringAtOffset));

            ClassWithStringAtOffset.BuildSample().VerifyTree(rootNode);
        }