Beispiel #1
0
        public void CreateAndDispose_serverRejectsCall_ShouldRetryAsked()
        {
            CustomeStaComCrossThreadInvoker invoker = null;
            var thread = new Thread(() =>
            {
                using (invoker = new CustomeStaComCrossThreadInvoker())
                {
                    FakeComServer.RetryRejectedCall(invoker, StaComCrossThreadInvoker.DEFAULT_RETRY_TIMEOUT + 1000);
                }
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
            Assert.IsTrue(invoker.ShouldRetryCalled);
        }
Beispiel #2
0
        public void CreateAndDispose_smallMaximumTotalWaitTimeAndVeryBusyComServer_Canceled()
        {
            var thread = new Thread(() =>
            {
                using (var invoker = new StaComCrossThreadInvoker(1000))
                {
                    FakeComServer.RetryRejectedCall(invoker, 1001);
                    // if really call to COM object here - could throw exceptions
                }
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
            Assert.AreEqual(StaComCrossThreadInvoker.CANCEL, FakeComServer.LastRetryResult);
        }