static void ValidateGlobalInstanceScenarios() { Console.WriteLine($"Running {nameof(ValidateGlobalInstanceScenarios)}..."); Console.WriteLine($"Validate RegisterAsGlobalInstance()..."); var wrappers1 = TestComWrappers.Global; wrappers1.RegisterAsGlobalInstance(); Assert.Throws <InvalidOperationException>( () => { wrappers1.RegisterAsGlobalInstance(); }, "Should not be able to re-register for global ComWrappers"); var wrappers2 = new TestComWrappers(); Assert.Throws <InvalidOperationException>( () => { wrappers2.RegisterAsGlobalInstance(); }, "Should not be able to reset for global ComWrappers"); Console.WriteLine($"Validate NotifyEndOfReferenceTrackingOnThread()..."); int hr; var cw = TestComWrappers.Global; // Trigger the thread lifetime end API and verify the callback occurs. hr = MockReferenceTrackerRuntime.Trigger_NotifyEndOfReferenceTrackingOnThread(); Assert.AreEqual(TestComWrappers.ReleaseObjectsCallAck, hr); }
private static void ValidateNotRegisteredForTrackerSupport() { Console.WriteLine($"Running {nameof(ValidateNotRegisteredForTrackerSupport)}..."); int hr = MockReferenceTrackerRuntime.Trigger_NotifyEndOfReferenceTrackingOnThread(); Assert.AreNotEqual(GlobalComWrappers.ReleaseObjectsCallAck, hr); }
private static void ValidateNotifyEndOfReferenceTrackingOnThread() { Console.WriteLine($"Running {nameof(ValidateNotifyEndOfReferenceTrackingOnThread)}..."); // Make global instance return invalid object so that the Exception thrown by // GlobalComWrappers.ReleaseObjects is marshalled using the built-in system. GlobalComWrappers.Instance.ReturnInvalid = true; // Trigger the thread lifetime end API and verify the callback occurs. int hr = MockReferenceTrackerRuntime.Trigger_NotifyEndOfReferenceTrackingOnThread(); Assert.AreEqual(GlobalComWrappers.ReleaseObjectsCallAck, hr); }