Exemple #1
0
        [Test] public void ForEachCallsLocalInitBodyLocalFinallyInOrder()
        {
            T[] sources = TestData <T> .MakeTestArray(_sampleSize);

            _sut = new ParallelCompletion <T, int>(_executor, _localInit, _body, _localFinally);
            _sut.ForEach(sources, Parallelism);

            (
                _localFinally.ActivityOf(x => x(Arg <int> .Is.Anything)).First
                >
                _body.ActivityOf(x => x(Arg <T> .Is.Anything, Arg <ILoopState> .Is.Anything, Arg <int> .Is.Anything)).First
                >
                _localInit.ActivityOf(x => x()).First
            )
            .AssertOccured();

            (
                _localFinally.ActivityOf(x => x(Arg <int> .Is.Anything)).Last
                >
                _body.ActivityOf(x => x(Arg <T> .Is.Anything, Arg <ILoopState> .Is.Anything, Arg <int> .Is.Anything)).Last
                >
                _localInit.ActivityOf(x => x()).Last
            )
            .AssertOccured();

            ThreadManager.JoinAndVerify();
        }
Exemple #2
0
        [Test] public void SubmitCopiesContextBeforeExecutesCall()
        {
            IContextCarrier cc = SetupContextCarrier();

            _call.Stub(x => x()).Return(TestData <T> .Two);
            var future = _sut.Submit(_call);

            Assert.IsTrue(future.IsDone);
            Assert.That(future.GetResult(), Is.EqualTo(TestData <T> .Two));

            Mockery.Assert(cc.ActivityOf(x => x.Restore()) < _call.ActivityOf(x => x()));
        }