public void Should_pass_exception_to_cleanup()
        {
            var builder = new FuncBuilder();

            var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork();

            builder.Register<IManageUnitsOfWork>(() => unitOfWork);
            var runner = new UnitOfWorkRunner
                         {
                             Builder = builder
                         };
            var exception = new Exception();
            runner.Begin();
            var aggregateException = Assert.Throws<AggregateException>(() => runner.AppendEndExceptionsAndRethrow(exception));
            Assert.AreSame(exception, unitOfWork.Exception);
            Assert.AreSame(exception, aggregateException.InnerExceptions.Single());
        }
        public void Should_append_end_exception_to_rethrow()
        {
            var builder = new FuncBuilder();

            var unitOfWork = new UnitOfWorkThatThrowsFromEnd();

            builder.Register<IManageUnitsOfWork>(() => unitOfWork);
            var runner = new UnitOfWorkRunner
            {
                Builder = builder
            };
            var exception = new Exception();
            runner.Begin();
            var aggregateException = Assert.Throws<AggregateException>(() => runner.AppendEndExceptionsAndRethrow(exception));
            var innerExceptions = aggregateException.InnerExceptions;
            Assert.AreSame(exception, innerExceptions[0]);
            Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, innerExceptions[1]);
        }
        public void Should_pass_exception_to_cleanup()
        {
            var builder = new FuncBuilder();

            var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork();

            builder.Register <IManageUnitsOfWork>(() => unitOfWork);
            var runner = new UnitOfWorkRunner
            {
                Builder = builder
            };
            var exception = new Exception();

            runner.Begin();
            var aggregateException = Assert.Throws <AggregateException>(() => runner.AppendEndExceptionsAndRethrow(exception));

            Assert.AreSame(exception, unitOfWork.Exception);
            Assert.AreSame(exception, aggregateException.InnerExceptions.Single());
        }
        public void Should_append_end_exception_to_rethrow()
        {
            var builder = new FuncBuilder();

            var unitOfWork = new UnitOfWorkThatThrowsFromEnd();

            builder.Register <IManageUnitsOfWork>(() => unitOfWork);
            var runner = new UnitOfWorkRunner
            {
                Builder = builder
            };
            var exception = new Exception();

            runner.Begin();
            var aggregateException = Assert.Throws <AggregateException>(() => runner.AppendEndExceptionsAndRethrow(exception));
            var innerExceptions    = aggregateException.InnerExceptions;

            Assert.AreSame(exception, innerExceptions[0]);
            Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, innerExceptions[1]);
        }