/// <summary> /// Handles an exception that occurred while publishing process manager commands. /// </summary> /// <param name="context">A <see cref="CommandPublisherExceptionContext"/> contains information about the exception that occurred.</param> /// <returns>A task representing the asynchronous operation.</returns> public Task Handle(CommandPublisherExceptionContext context) { if (context == null) { throw new ArgumentNullException(nameof(context)); } return(_handler.Invoke(context)); }
public void initializer_sets_Handled_to_false() { var sut = new CommandPublisherExceptionContext( typeof(ProcessManager), Guid.NewGuid(), new InvalidOperationException()); sut.Handled.Should().BeFalse(); }
public void constructor_sets_Exception_correctly() { var exception = new InvalidOperationException(); var sut = new CommandPublisherExceptionContext( typeof(ProcessManager), Guid.NewGuid(), exception); sut.Exception.Should().Be(exception); }
public void constructor_sets_ProcessManagerId_correctly() { var processManagerId = Guid.NewGuid(); var sut = new CommandPublisherExceptionContext( typeof(ProcessManager), processManagerId, new InvalidOperationException()); sut.ProcessManagerId.Should().Be(processManagerId); }
public void constructor_sets_ProcessManagerType_correctly() { Type processManagerType = typeof(ProcessManager); var sut = new CommandPublisherExceptionContext( processManagerType, Guid.NewGuid(), new InvalidOperationException()); sut.ProcessManagerType.Should().BeSameAs(processManagerType); }
public async Task Handle_relays_to_synchronous_action_correctly() { IFunctionProvider functionProvider = Mock.Of <IFunctionProvider>(); Action <CommandPublisherExceptionContext> action = functionProvider.Action; var sut = new DelegatingCommandPublisherExceptionHandler(action); var fixture = new Fixture(); CommandPublisherExceptionContext context = fixture.Create <CommandPublisherExceptionContext>(); await sut.Handle(context); Mock.Get(functionProvider).Verify(x => x.Action(context), Times.Once()); }
public async Task Handle_relays_to_asynchronous_action_correctly() { ICommandPublisherExceptionHandler handler = Mock.Of <ICommandPublisherExceptionHandler>(); Func <CommandPublisherExceptionContext, Task> action = handler.Handle; var sut = new DelegatingCommandPublisherExceptionHandler(action); var fixture = new Fixture(); CommandPublisherExceptionContext context = fixture.Create <CommandPublisherExceptionContext>(); await sut.Handle(context); Mock.Get(handler).Verify(x => x.Handle(context), Times.Once()); }
private async Task RunHandle(CommandPublisherExceptionContext context) { foreach (ICommandPublisherExceptionHandler handler in _handlers) { try { await handler.Handle(context).ConfigureAwait(false); } catch { } } }
public async Task Handle_invokes_all_inner_handler_functions() { // Arrange ICommandPublisherExceptionHandler[] handlers = new[] { Mock.Of <ICommandPublisherExceptionHandler>(), Mock.Of <ICommandPublisherExceptionHandler>(), Mock.Of <ICommandPublisherExceptionHandler>(), }; var fixture = new Fixture(); CommandPublisherExceptionContext context = fixture.Create <CommandPublisherExceptionContext>(); var sut = new CompositeCommandPublisherExceptionHandler(handlers); // Act await sut.Handle(context); // Assert foreach (ICommandPublisherExceptionHandler handler in handlers) { Mock.Get(handler).Verify(x => x.Handle(context), Times.Once()); } }
public Task Handle(CommandPublisherExceptionContext context) => Task.FromResult(true);