Example #1
0
    private static void MultiOverride()
    {
        FooBarBlahImpl fooBarBlah = new FooBarBlahImpl();
        IFoo           foo        = (IFoo)fooBarBlah;

        Console.WriteLine("Calling IFoo.Foo methods on FooBarBlahImpl...");
        Test.Assert(foo.Foo1(0) == 11111, "Calling IFoo.Foo1 on FooBarBlahImpl");
        Test.Assert(foo.Foo2(0) == 22222, "Calling IFoo.Foo2 on FooBarBlahImpl");
        Test.Assert(foo.Foo3(0) == 33333, "Calling IFoo.Foo3 on FooBarBlahImpl");
        Test.Assert(foo.Foo4(0) == 33333, "Calling IFoo.Foo4 on FooBarBlahImpl");
        Test.Assert(foo.Foo5(0) == 33333, "Calling IFoo.Foo5 on FooBarBlahImpl");
        Test.Assert(foo.Foo6(6) == 66, "Calling IFoo.Foo6 on FooBarBlahImpl");
        Test.Assert(foo.Foo7(7) == 77, "Calling IFoo.Foo7 on FooBarBlahImpl");
        Test.Assert(foo.Foo8(8) == 88, "Calling IFoo.Foo8 on FooBarBlahImpl");
        Test.Assert(foo.Foo9(9) == 99, "Calling IFoo.Foo9 on FooBarBlahImpl");

        IBar bar = (IBar)fooBarBlah;

        Console.WriteLine("Calling IBar.Bar methods on FooBarBlahImpl...");

        Test.Assert(bar.Bar1(0) == 11111, "Calling IBar.Bar1 on FooBarBlahImpl");
        Test.Assert(bar.Bar2(0) == 22222, "Calling IBar.Bar2 on FooBarBlahImpl");
        Test.Assert(bar.Bar3(0) == 33333, "Calling IBar.Bar3 on FooBarBlahImpl");
        Test.Assert(bar.Bar4(0) == 33333, "Calling IBar.Bar4 on FooBarBlahImpl");
        Test.Assert(bar.Bar5(0) == 33333, "Calling IBar.Bar5 on FooBarBlahImpl");
        Test.Assert(bar.Bar6(0) == 66, "Calling IBar.Bar6 on FooBarBlahImpl");
        Test.Assert(bar.Bar7(0) == 77, "Calling IBar.Bar7 on FooBarBlahImpl");
        Test.Assert(bar.Bar8(0) == 88, "Calling IBar.Bar8 on FooBarBlahImpl");
        Test.Assert(bar.Bar9(0) == 99, "Calling IBar.Bar9 on FooBarBlahImpl");

        IBlah blah = (IBlah)fooBarBlah;

        Console.WriteLine("Calling IBlah.Blah methods on FooBarBlahImpl...");

        Test.Assert(blah.Blah1(0) == 11111, "Calling IBlah.Blah1 on FooBarBlahImpl");
        Test.Assert(blah.Blah2(0) == 22222, "Calling IBlah.Blah1 on FooBarBlahImpl");
        Test.Assert(blah.Blah3(0) == 33333, "Calling IBlah.Blah1 on FooBarBlahImpl");
    }
Example #2
0
    private static void SingleOverride()
    {
        IBarImpl barImpl = new IBarImpl();
        IFoo     foo     = (IFoo)barImpl;

        Console.WriteLine("Calling IFoo.Foo methods on IBarImpl...");

        Test.Assert(foo.Foo1(1) == 11, "Calling IFoo.Foo1 on IBarImpl");
        Test.Assert(foo.Foo2(2) == 22, "Calling IFoo.Foo2 on IBarImpl");
        Test.Assert(foo.Foo3(3) == 33, "Calling IFoo.Foo3 on IBarImpl");
        Test.Assert(foo.Foo4(4) == 44, "Calling IFoo.Foo4 on IBarImpl");
        Test.Assert(foo.Foo5(5) == 55, "Calling IFoo.Foo5 on IBarImpl");
        Test.Assert(foo.Foo6(0) == 6, "Calling IFoo.Foo6 on IBarImpl");
        Test.Assert(foo.Foo7(0) == 7, "Calling IFoo.Foo7 on IBarImpl");
        Test.Assert(foo.Foo8(0) == 8, "Calling IFoo.Foo8 on IBarImpl");
        Test.Assert(foo.Foo9(0) == 9, "Calling IFoo.Foo9 on IBarImpl");

        IBar bar = (IBar)barImpl;

        Console.WriteLine("Calling IBar.Bar methods on IBarImpl...");

        Test.Assert(bar.Bar1(0) == 11, "Calling IBar.Bar1 on IBarImpl");
        Test.Assert(bar.Bar2(0) == 22, "Calling IBar.Bar2 on IBarImpl");
        Test.Assert(bar.Bar3(0) == 33, "Calling IBar.Bar3 on IBarImpl");
        Test.Assert(bar.Bar4(0) == 44, "Calling IBar.Bar4 on IBarImpl");
        Test.Assert(bar.Bar5(0) == 55, "Calling IBar.Bar5 on IBarImpl");
        Test.Assert(bar.Bar6(0) == 66, "Calling IBar.Bar6 on IBarImpl");
        Test.Assert(bar.Bar7(0) == 77, "Calling IBar.Bar7 on IBarImpl");
        Test.Assert(bar.Bar8(0) == 88, "Calling IBar.Bar8 on IBarImpl");
        Test.Assert(bar.Bar9(0) == 99, "Calling IBar.Bar9 on IBarImpl");

        IBlahImpl blahImpl = new IBlahImpl();

        foo = (IFoo)blahImpl;

        Test.Assert(foo.Foo1(1) == 11, "Calling IFoo.Foo1 on IBlahImpl");
        Test.Assert(foo.Foo2(2) == 22, "Calling IFoo.Foo2 on IBlahImpl");
        Test.Assert(foo.Foo3(3) == 33, "Calling IFoo.Foo3 on IBlahImpl");
        Test.Assert(foo.Foo4(4) == 44, "Calling IFoo.Foo4 on IBlahImpl");
        Test.Assert(foo.Foo5(5) == 55, "Calling IFoo.Foo5 on IBlahImpl");
        Test.Assert(foo.Foo6(6) == 66, "Calling IFoo.Foo6 on IBlahImpl");
        Test.Assert(foo.Foo7(7) == 77, "Calling IFoo.Foo7 on IBlahImpl");
        Test.Assert(foo.Foo8(8) == 88, "Calling IFoo.Foo8 on IBlahImpl");
        Test.Assert(foo.Foo9(9) == 99, "Calling IFoo.Foo9 on IBlahImpl");

        bar = (IBar)blahImpl;

        Console.WriteLine("Calling IBar.Bar methods on IBlahImpl...");

        Test.Assert(bar.Bar1(1) == 111, "Calling IBar.Bar1 on IBlahImpl");
        Test.Assert(bar.Bar2(2) == 222, "Calling IBar.Bar2 on IBlahImpl");
        Test.Assert(bar.Bar3(3) == 333, "Calling IBar.Bar3 on IBlahImpl");
        Test.Assert(bar.Bar4(4) == 444, "Calling IBar.Bar4 on IBlahImpl");
        Test.Assert(bar.Bar5(5) == 555, "Calling IBar.Bar5 on IBlahImpl");
        Test.Assert(bar.Bar6(0) == 66, "Calling IBar.Bar6 on IBlahImpl");
        Test.Assert(bar.Bar7(0) == 77, "Calling IBar.Bar7 on IBlahImpl");
        Test.Assert(bar.Bar8(0) == 88, "Calling IBar.Bar8 on IBlahImpl");
        Test.Assert(bar.Bar9(0) == 99, "Calling IBar.Bar9 on IBlahImpl");

        IBlah blah = (IBlah)blahImpl;

        Console.WriteLine("Calling IBlah.Blah methods on IBlahImpl...");

        Test.Assert(blah.Blah1(0) == 111, "Calling IBlah.Blah1 on IBlahImpl");
        Test.Assert(blah.Blah2(2) == 2222, "Calling IBlah.Blah1 on IBlahImpl");
        Test.Assert(blah.Blah3(3) == 3333, "Calling IBlah.Blah1 on IBlahImpl");
    }