Execute() public method

public Execute ( System.Action op ) : void
op System.Action
return void
Ejemplo n.º 1
0
        public void Should_pipe_remaining_operations_when_exception_thrown()
        {
            //arrange
            var handledException = false;
            var remainingJobsCalled = true;
            var remainingJobsCount = 0;
            Action<Exception> exCallback = exception => { handledException = true; };
            Action exOperation = () => { throw new Exception("Plain old exception"); };
            Executor = new TryCatchExecutor(exCallback);

            var wasCalled = 3.Of(false).ToList();
            var callbacks = new Action[wasCalled.Count];

            for (var i = 0; i < wasCalled.Count; i++)
            {
                var i1 = i;
                callbacks[i] = new Action(() => { wasCalled[i1] = true; });
            }
            callbacks[1] = exOperation;

            //act
            Executor.Execute(callbacks, actions =>
            {
                remainingJobsCalled = true;
                remainingJobsCount = actions.Count();
            });

            //assert
            Assert.IsFalse(wasCalled.All(x => x));
            Assert.IsTrue(handledException);
            Assert.IsTrue(remainingJobsCalled);
            Assert.AreEqual(1, remainingJobsCount);
        }
Ejemplo n.º 2
0
        public void Should_report_exception_when_thrown()
        {
            //arrange
            var handledException = false;
            Action<Exception> exCallback = exception => { handledException = true; };
            Action exOperation = () => { throw new Exception("Plain old exception"); };
            Executor = new TryCatchExecutor(exCallback);

            //act
            Executor.Execute(exOperation);

            //assert
            Assert.IsTrue(handledException);
        }
Ejemplo n.º 3
0
        public void Should_not_report_exception_when_not_thrown()
        {
            //arrange
            var handledException = false;
            var called = false;
            Action<Exception> exCallback = exception => { handledException = true; };
            Action exOperation = () => { called = true; };
            Executor = new TryCatchExecutor(exCallback);

            //act
            Executor.Execute(exOperation);

            //assert
            Assert.IsFalse(handledException);
            Assert.IsTrue(called);
        }