示例#1
0
    private static int TestMultipleInterfaces()
    {
        TestClass <int> testInt = new TestClass <int>(5);

        MyInterface myInterface = testInt as MyInterface;

        if (!myInterface.GetAString().Equals("TestClass"))
        {
            Console.Write("On type TestClass, MyInterface.GetAString() returned ");
            Console.Write(myInterface.GetAString());
            Console.WriteLine(" Expected: TestClass");
            return(Fail);
        }


        if (myInterface.GetAnInt() != 1)
        {
            Console.Write("On type TestClass, MyInterface.GetAnInt() returned ");
            Console.Write(myInterface.GetAnInt());
            Console.WriteLine(" Expected: 1");
            return(Fail);
        }

        Interface <int> itf = testInt as Interface <int>;

        if (itf.GetT() != 5)
        {
            Console.Write("On type TestClass, Interface<int>::GetT() returned ");
            Console.Write(itf.GetT());
            Console.WriteLine(" Expected: 5");
            return(Fail);
        }

        return(Pass);
    }