Beispiel #1
0
    public static void TestGenInterface_NonGenType()
    {
        IGen <int>    iIntc3    = new C3Int();
        IGen <object> iObjectc3 = new C3Object();
        IGen <string> iStringc3 = new C3String();

        // TEST4: test non generic virtual method
        if (iIntc3.method1() != 5 || iObjectc3.method1() != 5 || iStringc3.method1() != 5)
        {
            Console.WriteLine("Failed at TestGenInterface_NonGenType: non generic method");
            pass = false;
        }


        // TEST5: test generic virtual method
        if (iIntc3.method2 <int>() != 6 || iIntc3.method2 <object>() != 6 || iIntc3.method2 <string>() != 6 ||
            iIntc3.method2 <A <int> >() != 6 || iIntc3.method2 <S <string> >() != 6

            || iObjectc3.method2 <int>() != 6 || iObjectc3.method2 <object>() != 6 || iObjectc3.method2 <string>() != 6 ||
            iObjectc3.method2 <A <int> >() != 6 || iObjectc3.method2 <S <string> >() != 6

            || iStringc3.method2 <int>() != 6 || iStringc3.method2 <object>() != 6 || iStringc3.method2 <string>() != 6 ||
            iStringc3.method2 <A <int> >() != 6 || iStringc3.method2 <S <string> >() != 6
            )
        {
            Console.WriteLine("Failed at TestGenInterface_NonGenType: generic method");
            pass = false;
        }
    }
    public static void TestGenInterface_NonGenType()
    {
        IGen <int>    iIntc3    = new C3Int();
        IGen <object> iObjectc3 = new C3Object();
        IGen <string> iStringc3 = new C3String();

        // TEST4: test non generic virtual method

        Eval((iIntc3.method1().ToString()).Equals("5"));
        Eval((iObjectc3.method1().ToString()).Equals("5"));
        Eval((iStringc3.method1().ToString()).Equals("5"));



        // TEST5: test generic virtual method


        Eval((iIntc3.method2 <int>().ToString()).Equals("6"));
        Eval((iIntc3.method2 <object>().ToString()).Equals("6"));
        Eval((iIntc3.method2 <string>().ToString()).Equals("6"));
        Eval((iIntc3.method2 <A <int> >().ToString()).Equals("6"));
        Eval((iIntc3.method2 <S <string> >().ToString()).Equals("6"));

        Eval((iStringc3.method2 <int>().ToString()).Equals("6"));
        Eval((iStringc3.method2 <object>().ToString()).Equals("6"));
        Eval((iStringc3.method2 <string>().ToString()).Equals("6"));
        Eval((iStringc3.method2 <A <int> >().ToString()).Equals("6"));
        Eval((iStringc3.method2 <S <string> >().ToString()).Equals("6"));

        Eval((iObjectc3.method2 <int>().ToString()).Equals("6"));
        Eval((iObjectc3.method2 <object>().ToString()).Equals("6"));
        Eval((iObjectc3.method2 <string>().ToString()).Equals("6"));
        Eval((iObjectc3.method2 <A <int> >().ToString()).Equals("6"));
        Eval((iObjectc3.method2 <S <string> >().ToString()).Equals("6"));
    }