Exemple #1
0
        public void Test_ThreadAbort_WithFatalException()
        {
            TestFunction2 function = new TestFunction2();

            function.SetExecutionListener(_executionListenerMock);

            WxeStep step1 = MockRepository.GenerateMock <WxeStep> ();

            step1.Expect(mock => mock.Execute(_context)).WhenCalled(invocation => Thread.CurrentThread.Abort());
            function.Add(step1);

            var fatalExecutionException = new WxeFatalExecutionException(new Exception("Pause exception"), null);

            using (_mockRepository.Ordered())
            {
                _executionListenerMock.Expect(mock => mock.OnExecutionPlay(_context));
                _executionListenerMock.Expect(mock => mock.OnExecutionPause(_context)).Throw(fatalExecutionException);
            }
            _mockRepository.ReplayAll();

            try
            {
                function.Execute(_context);
                Assert.Fail();
            }
            catch (WxeFatalExecutionException actualException)
            {
                Assert.That(actualException, Is.SameAs(fatalExecutionException));
                Thread.ResetAbort();
            }
        }
Exemple #2
0
        public void Test_ChildStrategyThrowsFatalException()
        {
            var innerException = new WxeFatalExecutionException(new Exception("InnerListener Exception"), null);

            using (MockRepository.Ordered())
            {
                TransactionMock.Expect(mock => mock.EnterScope()).Return(ScopeMock);
                ChildTransactionStrategyMock.Expect(mock => mock.OnExecutionPlay(Context, ExecutionListenerStub)).Throw(innerException);
            }

            MockRepository.ReplayAll();

            try
            {
                _strategy.OnExecutionPlay(Context, ExecutionListenerStub);
                Assert.Fail("Expected Exception");
            }
            catch (WxeFatalExecutionException actualException)
            {
                Assert.That(actualException, Is.SameAs(innerException));
            }

            MockRepository.VerifyAll();
            Assert.That(_strategy.Scope, Is.Not.Null);
        }
        public void Test_ChildStrategyThrowsFatalException()
        {
            var innerException = new WxeFatalExecutionException(new Exception("ChildStrategy Exception"), null);

            InvokeOnExecutionPlay(_strategy);
            ChildTransactionStrategyMock.Expect(mock => mock.OnExecutionPause(Context, ExecutionListenerStub)).Throw(innerException);

            MockRepository.ReplayAll();

            try
            {
                _strategy.OnExecutionPause(Context, ExecutionListenerStub);
                Assert.Fail("Expected Exception");
            }
            catch (WxeFatalExecutionException actualException)
            {
                Assert.That(actualException, Is.SameAs(innerException));
            }

            MockRepository.VerifyAll();
            Assert.That(_strategy.Scope, Is.Not.Null);
        }