示例#1
0
        public static new ModerateClass CreateForTests(int seed)
        {
            var moderateClass = new ModerateClass(seed, seed % 2 == 1, "seed_" + seed)
            {
                _fieldPublic  = seed,
                _fieldPublic2 = seed + 1
            };

            moderateClass._structField       = new Struct(seed, moderateClass, SimpleClass.CreateForTests(seed));
            moderateClass._deeperStructField = new DeeperStruct(seed, SimpleClass.CreateForTests(seed));

            moderateClass._genericClassField = new GenericClass <SimpleClass>(moderateClass, SimpleClass.CreateForTests(seed));

            var seedSimple = seed + 1000;

            moderateClass.SimpleClassProperty = new SimpleClass(seedSimple, seed % 2 == 1, "seed_" + seedSimple);

            moderateClass._readonlySimpleClassField = new SimpleClass(seedSimple + 1, seed % 2 == 1, "seed_" + (seedSimple + 1));

            moderateClass.SimpleClassArray = new SimpleClass[10];

            for (var i = 1; i <= 10; i++)
            {
                moderateClass.SimpleClassArray[i - 1] = new SimpleClass(seedSimple + i, seed % 2 == 1, "seed_" + (seedSimple + i));
            }

            return(moderateClass);
        }
示例#2
0
        public static ComplexClass CreateForTests()
        {
            var complexClass = new ComplexClass();

            var dict1 = new DerivedDictionary <string, SimpleClass>();

            complexClass._sampleDictionary = dict1;

            dict1[typeof(ComplexClass).ToString()]  = new ComplexClass();
            dict1[typeof(ModerateClass).ToString()] = new ModerateClass(1, true, "madeInComplexClass");
            dict1[typeof(SimpleClass).ToString()]   = new SimpleClass(2, false, "madeInComplexClass");

            var dict2 = complexClass.ISampleDictionary;

            dict2[typeof(ComplexClass).ToString()]  = dict1[typeof(ComplexClass).ToString()];
            dict2[typeof(ModerateClass).ToString()] = dict1[typeof(ModerateClass).ToString()];
            dict2[typeof(SimpleClass).ToString()]   = new SimpleClass(2, false, "madeInComplexClass");

            var array1 = new ISimpleClass[2, 1, 1];

            array1[0, 0, 0] = new SimpleClass(4, false, "madeForMultiDimArray");
            array1[1, 0, 0] = new ComplexClass();
            complexClass._iSimpleMultiDimArray = array1;

            var array2 = new SimpleClass[2][][];

            array2[1]       = new SimpleClass[2][];
            array2[1][1]    = new SimpleClass[2];
            array2[1][1][1] = (SimpleClass)array1[0, 0, 0];
            complexClass._simpleMultiDimArray = array2;

            complexClass._structArray    = new Struct[2];
            complexClass._structArray[0] = new Struct(1, complexClass, SimpleClass.CreateForTests(5));
            complexClass._structArray[1] = new Struct(3, new SimpleClass(3, false, "inStruct"), SimpleClass.CreateForTests(6));

            return(complexClass);
        }