Пример #1
0
 private static MyInterface[] MakeInterfaceArray()
 {
     MyInterface[] itfs = new MyInterface[50];
     itfs[0]  = new Foo0();
     itfs[1]  = new Foo1();
     itfs[2]  = new Foo2();
     itfs[3]  = new Foo3();
     itfs[4]  = new Foo4();
     itfs[5]  = new Foo5();
     itfs[6]  = new Foo6();
     itfs[7]  = new Foo7();
     itfs[8]  = new Foo8();
     itfs[9]  = new Foo9();
     itfs[10] = new Foo10();
     itfs[11] = new Foo11();
     itfs[12] = new Foo12();
     itfs[13] = new Foo13();
     itfs[14] = new Foo14();
     itfs[15] = new Foo15();
     itfs[16] = new Foo16();
     itfs[17] = new Foo17();
     itfs[18] = new Foo18();
     itfs[19] = new Foo19();
     itfs[20] = new Foo20();
     itfs[21] = new Foo21();
     itfs[22] = new Foo22();
     itfs[23] = new Foo23();
     itfs[24] = new Foo24();
     itfs[25] = new Foo25();
     itfs[26] = new Foo26();
     itfs[27] = new Foo27();
     itfs[28] = new Foo28();
     itfs[29] = new Foo29();
     itfs[30] = new Foo30();
     itfs[31] = new Foo31();
     itfs[32] = new Foo32();
     itfs[33] = new Foo33();
     itfs[34] = new Foo34();
     itfs[35] = new Foo35();
     itfs[36] = new Foo36();
     itfs[37] = new Foo37();
     itfs[38] = new Foo38();
     itfs[39] = new Foo39();
     itfs[40] = new Foo40();
     itfs[41] = new Foo41();
     itfs[42] = new Foo42();
     itfs[43] = new Foo43();
     itfs[44] = new Foo44();
     itfs[45] = new Foo45();
     itfs[46] = new Foo46();
     itfs[47] = new Foo47();
     itfs[48] = new Foo48();
     itfs[49] = new Foo49();
     return(itfs);
 }
Пример #2
0
    private static int TestInterfaceCache()
    {
        MyInterface[] itfs = new MyInterface[50];

        itfs[0]  = new Foo0();
        itfs[1]  = new Foo1();
        itfs[2]  = new Foo2();
        itfs[3]  = new Foo3();
        itfs[4]  = new Foo4();
        itfs[5]  = new Foo5();
        itfs[6]  = new Foo6();
        itfs[7]  = new Foo7();
        itfs[8]  = new Foo8();
        itfs[9]  = new Foo9();
        itfs[10] = new Foo10();
        itfs[11] = new Foo11();
        itfs[12] = new Foo12();
        itfs[13] = new Foo13();
        itfs[14] = new Foo14();
        itfs[15] = new Foo15();
        itfs[16] = new Foo16();
        itfs[17] = new Foo17();
        itfs[18] = new Foo18();
        itfs[19] = new Foo19();
        itfs[20] = new Foo20();
        itfs[21] = new Foo21();
        itfs[22] = new Foo22();
        itfs[23] = new Foo23();
        itfs[24] = new Foo24();
        itfs[25] = new Foo25();
        itfs[26] = new Foo26();
        itfs[27] = new Foo27();
        itfs[28] = new Foo28();
        itfs[29] = new Foo29();
        itfs[30] = new Foo30();
        itfs[31] = new Foo31();
        itfs[32] = new Foo32();
        itfs[33] = new Foo33();
        itfs[34] = new Foo34();
        itfs[35] = new Foo35();
        itfs[36] = new Foo36();
        itfs[37] = new Foo37();
        itfs[38] = new Foo38();
        itfs[39] = new Foo39();
        itfs[40] = new Foo40();
        itfs[41] = new Foo41();
        itfs[42] = new Foo42();
        itfs[43] = new Foo43();
        itfs[44] = new Foo44();
        itfs[45] = new Foo45();
        itfs[46] = new Foo46();
        itfs[47] = new Foo47();
        itfs[48] = new Foo48();
        itfs[49] = new Foo49();

        StringBuilder sb      = new StringBuilder();
        int           counter = 0;

        for (int i = 0; i < 50; i++)
        {
            sb.Append(itfs[i].GetAString());
            counter += itfs[i].GetAnInt();
        }

        string expected = "Foo0Foo1Foo2Foo3Foo4Foo5Foo6Foo7Foo8Foo9Foo10Foo11Foo12Foo13Foo14Foo15Foo16Foo17Foo18Foo19Foo20Foo21Foo22Foo23Foo24Foo25Foo26Foo27Foo28Foo29Foo30Foo31Foo32Foo33Foo34Foo35Foo36Foo37Foo38Foo39Foo40Foo41Foo42Foo43Foo44Foo45Foo46Foo47Foo48Foo49";

        if (!expected.Equals(sb.ToString()))
        {
            Console.WriteLine("Concatenating strings from interface calls failed.");
            Console.Write("Expected: ");
            Console.WriteLine(expected);
            Console.Write(" Actual: ");
            Console.WriteLine(sb.ToString());
            return(Fail);
        }

        if (counter != 1225)
        {
            Console.WriteLine("Summing ints from interface calls failed.");
            Console.WriteLine("Expected: 1225");
            Console.Write("Actual: ");
            Console.WriteLine(counter);
            return(Fail);
        }

        return(100);
    }