Пример #1
0
        static void Validate_Activation()
        {
            Console.WriteLine($"{nameof(Validate_Activation)}...");

            var test = new CoClass.ConsumeNETServerTesting();

            test.ReleaseResources();

            // The CoClass should be the activated type, _not_ the activation interface.
            Assert.AreEqual(test.GetType(), typeof(CoClass.ConsumeNETServerTestingClass));
        }
Пример #2
0
        static void Validate_CCW_Wasnt_Unwrapped()
        {
            Console.WriteLine($"{nameof(Validate_CCW_Wasnt_Unwrapped)}...");

            var test = new CoClass.ConsumeNETServerTesting();

            test.ReleaseResources();

            // The CoClass should be the activated type, _not_ the implementation class.
            // This indicates the real implementation class is wrapped in its CCW and exposed
            // to the runtime as an RCW.
            Assert.AreNotEqual(test.GetType(), typeof(ConsumeNETServerTesting));
        }
Пример #3
0
        static void Validate_Activation()
        {
            Console.WriteLine($"{nameof(Validate_Activation)}...");

            var test = new CoClass.ConsumeNETServerTesting();

            test.ReleaseResources();

            // The CoClass should be the activated type, _not_ the activation interface.
            Assert.Equal(test.GetType(), typeof(CoClass.ConsumeNETServerTestingClass));
            Assert.True(typeof(CoClass.ConsumeNETServerTestingClass).IsCOMObject);
            Assert.False(typeof(CoClass.ConsumeNETServerTesting).IsCOMObject);
            Assert.True(Marshal.IsComObject(test));
        }
Пример #4
0
        static void Validate_Server_CCW_RCW()
        {
            Console.WriteLine($"{nameof(Validate_Server_CCW_RCW)}...");

            // Validate the server side view is consistent
            var test = new CoClass.ConsumeNETServerTesting();

            try
            {
                Assert.IsTrue(test.EqualByCCW(test));
                Assert.IsTrue(test.NotEqualByRCW(test));
            }
            finally
            {
                test.ReleaseResources();
            }
        }
Пример #5
0
        static void Validate_Client_CCW_RCW()
        {
            Console.WriteLine($"{nameof(Validate_Client_CCW_RCW)}...");

            IntPtr ccw = IntPtr.Zero;

            // Validate the client side view is consistent
            var test = new CoClass.ConsumeNETServerTesting();

            try
            {
                ccw = test.GetCCW();
                object rcw  = Marshal.GetObjectForIUnknown(ccw);
                object inst = test.GetRCW();
                Assert.AreEqual(rcw, inst);
            }
            finally
            {
                test.ReleaseResources();
            }
        }