Beispiel #1
0
        public void thread_action_throws(int throwingThreadIndex)
        {
            var exceptionWasThrown = false;

            try
            {
                MultiThreadsTestUtils.TestOnThreads <object>(threadIndex =>
                {
                    if (throwingThreadIndex == threadIndex)
                    {
                        throw new DummyTestException(threadIndex.ToString());
                    }

                    return(null);
                });
            }
            catch (AggregateException ex)
            {
                exceptionWasThrown = true;
                ex.InnerExceptions.Should().ContainSingle();
                // ReSharper disable once PossibleNullReferenceException
                ex.InnerException.GetType().Should().Be(typeof(DummyTestException));
                ex.InnerException.Message.Should().Be(throwingThreadIndex.ToString());
            }
            exceptionWasThrown.Should().BeTrue();
        }
Beispiel #2
0
        public void thread_action_returns_string()
        {
            var results = MultiThreadsTestUtils.TestOnThreads(threadIndex => (threadIndex * threadIndex).ToString());

            results.ForEachIndexed((threadResult, threadIndex) => threadResult.Should().Be((threadIndex * threadIndex).ToString()));
        }