Represents an exception in case IWorkItemResult.GetResult has been timed out
Наследование: Exception
Пример #1
0
        public void Get_UnderlyingGetResultThrowsException_RethrowsInnerException()
        {
            // To avoid leaking STP's WorkItemResultException out beyond our thread pooling layer,
            // our wrappers around STP should unwrap the exception thrown by the pool and just
            // rethrow its inner exception, which should be what got thrown from ExecuteAsync().

            var inner = new ExpectedTestException("Root cause inner");
            var cause = new ExpectedTestException("Test root cause", inner);
            var itemException = new WorkItemResultException("Work item result exception", cause);

            var timeout = TimeSpan.FromSeconds(1);

            var mockWorkItemResult = new Mock<IWorkItemResult<object>>();
            mockWorkItemResult.Setup(m => m.GetResult(timeout, false)).Throws(itemException);

            var stpWorkItem = new StpWorkItem<object>(mockWorkItemResult.Object);

            try
            {
                stpWorkItem.Get(new CancellationToken(), timeout);
            }
            catch (ExpectedTestException e)
            {
                Assert.Equal(cause, e);
                Assert.Equal(inner, e.InnerException);
                return; // Expected.
            }
            
            AssertX.FailExpectedException();
        }