/// <summary>
    /// Test case set for ComVisible. The assembly is set as [assembly: ComVisible(false)]
    /// </summary>
    /// <returns></returns>
    private static void RunComVisibleTests()
    {
        int fooSuccessVal = 0;

        //
        // Tests for class with ComVisible(true)
        //
        Console.WriteLine("Class with ComVisible(true)");
        ClassVisibleTrueServer visibleBaseClass = new ClassVisibleTrueServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(1, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(2, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceWithoutVisible((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(4, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrueNoGuid");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrueNoGuid((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(6, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotVisibleNoGuid");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceNotVisibleNoGuid((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(16, fooSuccessVal);

        //
        // Tests for nested Interface in a class with ComVisible(true)
        //
        Console.WriteLine("Nested Interface in a class with ComVisible(true)");

        Console.WriteLine("CCWTest_InterfaceComImport_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport_ComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(101, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_ComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(102, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse_ComImport");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse_ComImport((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_VisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(104, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_VisibleFalse");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_VisibleFalse((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(106, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotPublic_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));

        //
        // Tests for class with ComVisible(false)
        //
        Console.WriteLine("Class with ComVisible(false)");
        ClassVisibleFalseServer visibleFalseBaseClass = new ClassVisibleFalseServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)visibleFalseBaseClass, out fooSuccessVal));
        Assert.Equal(120, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)visibleFalseBaseClass, out fooSuccessVal));
        Assert.Equal(121, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)visibleFalseBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceWithoutVisible((object)visibleFalseBaseClass, out fooSuccessVal));
        Assert.Equal(123, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)visibleFalseBaseClass, out fooSuccessVal));

        //
        // Tests for class without ComVisible()
        //
        Console.WriteLine("Class without ComVisible()");
        ClassWithoutVisibleServer withoutVisibleBaseClass = new ClassWithoutVisibleServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)withoutVisibleBaseClass, out fooSuccessVal));
        Assert.Equal(130, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)withoutVisibleBaseClass, out fooSuccessVal));
        Assert.Equal(131, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)withoutVisibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceWithoutVisible((object)withoutVisibleBaseClass, out fooSuccessVal));
        Assert.Equal(133, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)withoutVisibleBaseClass, out fooSuccessVal));


        //
        // Tests for generic class with ComVisible(true)
        //
        Console.WriteLine("Generic class with ComVisible(true)");
        ClassGenericServer <int> genericServer = new ClassGenericServer <int>();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)genericServer, out fooSuccessVal));
        Assert.Equal(140, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)genericServer, out fooSuccessVal));
        Assert.Equal(141, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceGenericVisibleTrue");
        Assert.Equal(Helpers.COR_E_INVALIDOPERATION, CCWTest_InterfaceGenericVisibleTrue((object)genericServer, out fooSuccessVal));

        //
        // Tests for nested class with ComVisible(true)
        //
        Console.WriteLine("Nested class with ComVisible(true)");
        NestedClassVisibleTrueServer visibleNestedBaseClass = new NestedClassVisibleTrueServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(10, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(11, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceWithoutVisible((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(13, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)visibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested Interface in a nested class with ComVisible(true)
        //
        Console.WriteLine("Nested Interface in a nested class with ComVisible(true)");

        Console.WriteLine("CCWTest_NestedInterfaceNestedInClass");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceNestedInClass((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(110, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceComImport_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(111, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(112, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse_ComImport");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_VisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(114, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_VisibleFalse");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_VisibleFalse((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(116, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested class with ComVisible(false)
        //
        Console.WriteLine("Nested class with ComVisible(false)");
        NestedClassVisibleFalseServer visibleFalseNestedBaseClass = new NestedClassVisibleFalseServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)visibleFalseNestedBaseClass, out fooSuccessVal));
        Assert.Equal(20, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)visibleFalseNestedBaseClass, out fooSuccessVal));
        Assert.Equal(21, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)visibleFalseNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceWithoutVisible((object)visibleFalseNestedBaseClass, out fooSuccessVal));
        Assert.Equal(23, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)visibleFalseNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested class without ComVisible()
        //
        Console.WriteLine("Nested class without ComVisible()");
        NestedClassWithoutVisibleServer withoutVisibleNestedBaseClass = new NestedClassWithoutVisibleServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)withoutVisibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(30, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)withoutVisibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(31, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)withoutVisibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceWithoutVisible((object)withoutVisibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(33, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)withoutVisibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for generic nested class with ComVisible(true)
        //
        Console.WriteLine("Nested generic class with ComVisible(true)");
        NestedClassGenericServer <int> nestedGenericServer = new NestedClassGenericServer <int>();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)nestedGenericServer, out fooSuccessVal));
        Assert.Equal(40, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)nestedGenericServer, out fooSuccessVal));
        Assert.Equal(41, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceGenericVisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceGenericVisibleTrue((object)nestedGenericServer, out fooSuccessVal));
    }
Exemple #2
0
    /// <summary>
    /// Test case set for ComVisible. The assembly is set as [assembly: ComVisible(false)]
    /// </summary>
    /// <returns></returns>
    private static void RunComVisibleTests()
    {
        int fooSuccessVal = 0;

        //
        // Tests for class with ComVisible(true)
        //
        Console.WriteLine("Class with ComVisible(true)");
        ClassVisibleTrueServer visibleBaseClass = new ClassVisibleTrueServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(1, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(2, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceWithoutVisible((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrueNoGuid");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrueNoGuid((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(6, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrueNoGuidGenericInterface");
        Assert.Equal(Helpers.COR_E_GENERICMETHOD, CCWTest_InterfaceVisibleTrueNoGuidGenericInterface((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceNotVisibleNoGuid");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotVisibleNoGuid((object)visibleBaseClass, out fooSuccessVal));

        //
        // Tests for nested Interface in a class with ComVisible(true)
        //
        Console.WriteLine("Nested Interface in a class with ComVisible(true)");

        Console.WriteLine("CCWTest_InterfaceComImport_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport_ComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(101, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_ComImport((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(102, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse_ComImport");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse_ComImport((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_VisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(104, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceVisibleTrue_VisibleFalse");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue_VisibleFalse((object)visibleBaseClass, out fooSuccessVal));
        Assert.Equal(106, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceNotPublic_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic_VisibleTrue((object)visibleBaseClass, out fooSuccessVal));

        //
        // Tests for class with ComVisible(false)
        //
        Console.WriteLine("Class with ComVisible(false)");
        ClassVisibleFalseServer visibleFalseBaseClass = new ClassVisibleFalseServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)visibleFalseBaseClass, out fooSuccessVal));
        Assert.Equal(120, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)visibleFalseBaseClass, out fooSuccessVal));
        Assert.Equal(121, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)visibleFalseBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceWithoutVisible((object)visibleFalseBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)visibleFalseBaseClass, out fooSuccessVal));

        //
        // Tests for class without ComVisible()
        //
        Console.WriteLine("Class without ComVisible()");
        ClassWithoutVisibleServer withoutVisibleBaseClass = new ClassWithoutVisibleServer();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)withoutVisibleBaseClass, out fooSuccessVal));
        Assert.Equal(130, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)withoutVisibleBaseClass, out fooSuccessVal));
        Assert.Equal(131, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceVisibleFalse((object)withoutVisibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceWithoutVisible((object)withoutVisibleBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_InterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_InterfaceNotPublic((object)withoutVisibleBaseClass, out fooSuccessVal));

        //
        // Tests for generic class with ComVisible(true)
        //
        Console.WriteLine("Generic class with ComVisible(true)");
        ClassGenericServer <int> genericServer = new ClassGenericServer <int>();

        Console.WriteLine("CCWTest_InterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceComImport((object)genericServer, out fooSuccessVal));
        Assert.Equal(140, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)genericServer, out fooSuccessVal));
        Assert.Equal(141, fooSuccessVal);

        Console.WriteLine("CCWTest_InterfaceGenericVisibleTrue");
        Assert.Equal(Helpers.COR_E_INVALIDOPERATION, CCWTest_InterfaceGenericVisibleTrue((object)genericServer, out fooSuccessVal));

        //
        // Tests for nested class with ComVisible(true)
        //
        Console.WriteLine("Nested class with ComVisible(true)");
        NestedClassVisibleTrueServer visibleNestedBaseClass = new NestedClassVisibleTrueServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(10, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(11, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceWithoutVisible((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)visibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested Interface in a nested class with ComVisible(true)
        //
        Console.WriteLine("Nested Interface in a nested class with ComVisible(true)");

        Console.WriteLine("CCWTest_NestedInterfaceNestedInClass");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceNestedInClass((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(110, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrueNoGuid");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrueNoGuid((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(50, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNestedInClassNoGuid");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceNestedInClassNoGuid((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(51, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceComImport_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(111, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_ComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(112, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse_ComImport");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse_ComImport((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_VisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(114, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue_VisibleFalse");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue_VisibleFalse((object)visibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(116, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic_VisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic_VisibleTrue((object)visibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested class with ComVisible(false)
        //
        Console.WriteLine("Nested class with ComVisible(false)");
        NestedClassVisibleFalseServer visibleFalseNestedBaseClass = new NestedClassVisibleFalseServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)visibleFalseNestedBaseClass, out fooSuccessVal));
        Assert.Equal(20, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)visibleFalseNestedBaseClass, out fooSuccessVal));
        Assert.Equal(21, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)visibleFalseNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceWithoutVisible((object)visibleFalseNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)visibleFalseNestedBaseClass, out fooSuccessVal));

        //
        // Tests for nested class without ComVisible()
        //
        Console.WriteLine("Nested class without ComVisible()");
        NestedClassWithoutVisibleServer withoutVisibleNestedBaseClass = new NestedClassWithoutVisibleServer();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)withoutVisibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(30, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)withoutVisibleNestedBaseClass, out fooSuccessVal));
        Assert.Equal(31, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleFalse");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceVisibleFalse((object)withoutVisibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceWithoutVisible");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceWithoutVisible((object)withoutVisibleNestedBaseClass, out fooSuccessVal));

        Console.WriteLine("CCWTest_NestedInterfaceNotPublic");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceNotPublic((object)withoutVisibleNestedBaseClass, out fooSuccessVal));

        //
        // Tests for generic nested class with ComVisible(true)
        //
        Console.WriteLine("Nested generic class with ComVisible(true)");
        NestedClassGenericServer <int> nestedGenericServer = new NestedClassGenericServer <int>();

        Console.WriteLine("CCWTest_NestedInterfaceComImport");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceComImport((object)nestedGenericServer, out fooSuccessVal));
        Assert.Equal(40, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_NestedInterfaceVisibleTrue((object)nestedGenericServer, out fooSuccessVal));
        Assert.Equal(41, fooSuccessVal);

        Console.WriteLine("CCWTest_NestedInterfaceGenericVisibleTrue");
        Assert.Equal(Helpers.E_NOINTERFACE, CCWTest_NestedInterfaceGenericVisibleTrue((object)nestedGenericServer, out fooSuccessVal));

        //
        // Tests for class with ComVisible(true) without Custom Attribute Guid.
        //
        Console.WriteLine("Class with ComVisible(true) without GUID");
        ClassVisibleTrueServerNoGuid visibleBaseClassNoGuid = new ClassVisibleTrueServerNoGuid();

        Console.WriteLine("CCWTest_InterfaceVisibleTrue");
        Assert.Equal(Helpers.S_OK, CCWTest_InterfaceVisibleTrue((object)visibleBaseClassNoGuid, out fooSuccessVal));
        Assert.Equal(150, fooSuccessVal);

        //
        // Tests for get the GetTypeInfo().GUID for Interface and class without Custom Attribute Guid.
        //
        Console.WriteLine("GetTypeInfo().GUID for Interface and Class without GUID");

        Console.WriteLine("IInterfaceVisibleTrueNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("ad50a327-d23a-38a4-9d6e-b32b32acf572"), typeof(IInterfaceVisibleTrueNoGuid).GetTypeInfo().GUID);

        Console.WriteLine("IInterfaceNotVisibleNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("b45587ec-9671-35bc-8b8e-f6bfb18a4d3a"), typeof(IInterfaceNotVisibleNoGuid).GetTypeInfo().GUID);

        Console.WriteLine("IDerivedInterfaceVisibleTrueNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("c3f73319-f6b3-3ef6-a095-8cb04fb8cf8b"), typeof(IDerivedInterfaceVisibleTrueNoGuid).GetTypeInfo().GUID);

        Console.WriteLine("IInterfaceVisibleTrueNoGuidGeneric.GUID");
        Assert.Equal <Guid>(new Guid("50c0a59c-b6e1-36dd-b488-a905b54910d4"), typeof(IInterfaceVisibleTrueNoGuidGeneric).GetTypeInfo().GUID);

        Console.WriteLine("IInterfaceVisibleTrueNoGuidGenericInterface.GUID");
        Assert.Equal <Guid>(new Guid("384f0b5c-28d0-368c-8c7e-5e31a84a5c84"), typeof(IInterfaceVisibleTrueNoGuidGenericInterface).GetTypeInfo().GUID);

        Console.WriteLine("ClassVisibleTrueServerNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("afb3aafc-75bc-35d3-be41-a399c2701929"), typeof(ClassVisibleTrueServerNoGuid).GetTypeInfo().GUID);

        Console.WriteLine("INestedInterfaceNestedInClassNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("486bcec9-904d-3445-871c-e7084a52eb1a"), typeof(NestedClass.INestedInterfaceNestedInClassNoGuid).GetTypeInfo().GUID);

        Console.WriteLine("INestedInterfaceVisibleTrueNoGuid.GUID");
        Assert.Equal <Guid>(new Guid("0ea2cb33-db9f-3655-9240-47ef1dea0f1e"), typeof(INestedInterfaceVisibleTrueNoGuid).GetTypeInfo().GUID);
    }