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);
}