public void Should_append_end_exception_to_rethrow() { var builder = new FakeBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(() => unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(builder), Throws.InvalidOperationException.And.SameAs(unitOfWork.ExceptionThrownFromEnd)); }
public void Should_append_end_exception_to_rethrow() { var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); var services = new ServiceCollection(); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(services), Throws.InvalidOperationException.And.SameAs(unitOfWork.ExceptionThrownFromEnd)); }
public void Should_append_end_exception_to_rethrow() { var builder = new FakeBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(() => unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async () => await InvokeBehavior(builder), Throws.InvalidOperationException.And.SameAs(unitOfWork.ExceptionThrownFromEnd)); }
public void Should_append_end_exception_to_rethrow() { var builder = new FuncBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(() => unitOfWork); //since it is a single exception then it will not be an AggregateException var exception = Assert.Throws <InvalidOperationException>(() => InvokeBehavior(builder)); Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, exception); }
public void Should_append_end_exception_to_rethrow() { var builder = new FuncBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(() => unitOfWork); var aggregateException = Assert.Throws<AggregateException>(() => InvokeBehavior(builder)); Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, aggregateException.InnerExceptions[0]); }
public void Should_call_all_end_even_if_one_or_more_of_them_throws() { var builder = new FakeBuilder(); var unitOfWorkThatThrows = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register <IManageUnitsOfWork>(unitOfWorkThatThrows, unitOfWork); Assert.That(async() => await InvokeBehavior(builder), Throws.InvalidOperationException); Assert.True(unitOfWork.EndCalled); }
public void Should_append_end_exception_to_rethrow() { var builder = new FuncBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(() => unitOfWork); //since it is a single exception then it will not be an AggregateException var exception = Assert.Throws<InvalidOperationException>(() => InvokeBehavior(builder)); Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, exception); }
public void Should_append_end_exception_to_rethrow() { var builder = new FuncBuilder(); var unitOfWork = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(() => unitOfWork); var aggregateException = Assert.Throws <AggregateException>(() => InvokeBehavior(builder)); Assert.AreSame(unitOfWork.ExceptionThrownFromEnd, aggregateException.InnerExceptions[0]); }
public void Should_call_all_end_even_if_one_or_more_of_them_throws() { var services = new ServiceCollection(); var unitOfWorkThatThrows = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWorkThatThrows); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWork); Assert.That(async() => await InvokeBehavior(services), Throws.InvalidOperationException); Assert.True(unitOfWork.EndCalled); }
public void Should_pass_exception_to_cleanup() { var builder = new FakeBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(unitOfWork, throwingUoW); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(builder), Throws.InstanceOf <InvalidOperationException>().And.SameAs(throwingUoW.ExceptionThrownFromEnd)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); }
public void Should_pass_exception_to_cleanup() { var services = new ServiceCollection(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWork); services.AddTransient <IManageUnitsOfWork>(sp => throwingUoW); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(services), Throws.InstanceOf <InvalidOperationException>().And.SameAs(throwingUoW.ExceptionThrownFromEnd)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); }
public void Should_pass_exception_to_cleanup() { var builder = new FuncBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(() => unitOfWork); builder.Register<IManageUnitsOfWork>(() => throwingUoW); var aggregateException = Assert.Throws<AggregateException>(() => InvokeBehavior(builder)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, aggregateException.InnerExceptions.Single()); }
public void Should_pass_exception_to_cleanup() { var builder = new FuncBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(() => unitOfWork); builder.Register <IManageUnitsOfWork>(() => throwingUoW); var aggregateException = Assert.Throws <AggregateException>(() => InvokeBehavior(builder)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, aggregateException.InnerExceptions.Single()); }
public void When_first_throw_second_is_cleaned_up() { var builder = new FuncBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register <IManageUnitsOfWork>(() => unitOfWorkThatThrowsFromEnd); builder.Register <IManageUnitsOfWork>(() => unitOfWork); Assert.Throws <AggregateException>(() => InvokeBehavior(builder)); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void When_first_throw_second_is_cleaned_up() { var builder = new FakeBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register <IManageUnitsOfWork>(unitOfWorkThatThrowsFromEnd, unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(builder), Throws.InvalidOperationException); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void Should_pass_exception_to_cleanup() { var builder = new FuncBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register <IManageUnitsOfWork>(() => unitOfWork); builder.Register <IManageUnitsOfWork>(() => throwingUoW); //since it is a single exception then it will not be an AggregateException var exception = Assert.Throws <InvalidOperationException>(() => InvokeBehavior(builder)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, exception); }
public void When_first_throw_second_is_cleaned_up() { var builder = new FakeBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register<IManageUnitsOfWork>(unitOfWorkThatThrowsFromEnd, unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async () => await InvokeBehavior(builder), Throws.InvalidOperationException); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void When_first_throw_second_is_cleaned_up() { var services = new ServiceCollection(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWorkThatThrowsFromEnd); services.AddTransient <IManageUnitsOfWork>(sp => unitOfWork); //since it is a single exception then it will not be an AggregateException Assert.That(async() => await InvokeBehavior(services), Throws.InvalidOperationException); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
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_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 When_first_throw_second_is_cleaned_up() { var builder = new FuncBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register <IManageUnitsOfWork>(() => unitOfWorkThatThrowsFromEnd); builder.Register <IManageUnitsOfWork>(() => unitOfWork); var runner = new UnitOfWorkRunner { Builder = builder }; runner.Begin(); Assert.Throws <InvalidOperationException>(runner.End); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void Should_call_all_end_even_if_one_or_more_of_them_throws() { var builder = new FakeBuilder(); var unitOfWorkThatThrows = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register<IManageUnitsOfWork>(unitOfWorkThatThrows, unitOfWork); Assert.That(async () => await InvokeBehavior(builder), Throws.InvalidOperationException); Assert.True(unitOfWork.EndCalled); }
public void Should_pass_exception_to_cleanup() { var builder = new FakeBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(unitOfWork, throwingUoW); //since it is a single exception then it will not be an AggregateException Assert.That(async () => await InvokeBehavior(builder), Throws.InstanceOf<InvalidOperationException>().And.SameAs(throwingUoW.ExceptionThrownFromEnd)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); }
public void When_first_throw_second_is_cleaned_up() { var builder = new FuncBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register<IManageUnitsOfWork>(() => unitOfWorkThatThrowsFromEnd); builder.Register<IManageUnitsOfWork>(() => unitOfWork); Assert.Throws<AggregateException>(() => InvokeBehavior(builder)); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void When_first_throw_second_is_cleaned_up() { var builder = new FuncBuilder(); var unitOfWorkThatThrowsFromEnd = new UnitOfWorkThatThrowsFromEnd(); var unitOfWork = new UnitOfWork(); builder.Register<IManageUnitsOfWork>(() => unitOfWorkThatThrowsFromEnd); builder.Register<IManageUnitsOfWork>(() => unitOfWork); var runner = new UnitOfWorkRunner { Builder = builder }; runner.Begin(); Assert.Throws<InvalidOperationException>(runner.End); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.BeginCalled); Assert.IsTrue(unitOfWorkThatThrowsFromEnd.EndCalled); Assert.IsTrue(unitOfWork.BeginCalled); Assert.IsTrue(unitOfWork.EndCalled); }
public void Should_pass_exception_to_cleanup() { var builder = new FuncBuilder(); var unitOfWork = new CaptureExceptionPassedToEndUnitOfWork(); var throwingUoW = new UnitOfWorkThatThrowsFromEnd(); builder.Register<IManageUnitsOfWork>(() => unitOfWork); builder.Register<IManageUnitsOfWork>(() => throwingUoW); //since it is a single exception then it will not be an AggregateException var exception = Assert.Throws<InvalidOperationException>(() => InvokeBehavior(builder)); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, unitOfWork.Exception); Assert.AreSame(throwingUoW.ExceptionThrownFromEnd, exception); }