public void PublishAsync_WhenCalledWithUnsupportedCommandType_ThrowsIntranetCommandBusException() { ICommandBus sut = CreateSut(new List <ICommandHandler>(0)); Mock <ICommand> commandMock = new Mock <ICommand>(); IntranetCommandBusException result = Assert.ThrowsAsync <IntranetCommandBusException>(async() => await sut.PublishAsync <ICommand, object>(commandMock.Object)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.NoCommandHandlerSupportingCommandWithResultType)); }
public void PublishAsync_WhenSupportingCommandHandlerThrowsException_ThrowsIntranetCommandBusExceptionWithCorrectInnerException() { Exception exception = _fixture.Create <Exception>(); Mock <ICommandHandler <TestCommand, object> > commandHandlerMock = CreateCommandHandlerMockWithResult <TestCommand, object>(_fixture.Create <object>(), exception); ICommandBus sut = CreateSut(CreateCommandHandlerMockCollection(commandHandlerMock.Object)); IntranetCommandBusException result = Assert.ThrowsAsync <IntranetCommandBusException>(async() => await sut.PublishAsync <TestCommand, object>(new TestCommand())); Assert.That(result.InnerException, Is.EqualTo(exception)); }
public void PublishAsync_WhenSupportingCommandHandlerThrowsException_ThrowsIntranetCommandBusExceptionWithCorrectErrorCode() { Exception exception = _fixture.Create <Exception>(); Mock <ICommandHandler <TestCommand> > commandHandlerMock = CreateCommandHandlerMockWithoutResult <TestCommand>(exception); ICommandBus sut = CreateSut(CreateCommandHandlerMockCollection(commandHandlerMock.Object)); IntranetCommandBusException result = Assert.ThrowsAsync <IntranetCommandBusException>(async() => await sut.PublishAsync(new TestCommand())); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ErrorWhilePublishingCommandWithoutResultType)); }
public void PublishAsync_WhenSupportingCommandHandlerThrowsAggregateExceptionWhereInnerExceptionIsNotIntranetExceptionBase_ThrowsIntranetCommandBusExceptionWithCorrectErrorCode() { AggregateException aggregateException = new AggregateException(_fixture.Create <Exception>()); Mock <ICommandHandler <TestCommand, object> > commandHandlerMock = CreateCommandHandlerMockWithResult <TestCommand, object>(_fixture.Create <object>(), aggregateException); ICommandBus sut = CreateSut(CreateCommandHandlerMockCollection(commandHandlerMock.Object)); IntranetCommandBusException result = Assert.ThrowsAsync <IntranetCommandBusException>(async() => await sut.PublishAsync <TestCommand, object>(new TestCommand())); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ErrorWhilePublishingCommandWithResultType)); }
public void PublishAsync_WhenSupportingCommandHandlerThrowsAggregateExceptionWhereInnerExceptionIsNotIntranetExceptionBase_ThrowsIntranetCommandBusExceptionWithCorrectInnerException() { Exception innerException = _fixture.Create <Exception>(); AggregateException aggregateException = new AggregateException(innerException); Mock <ICommandHandler <TestCommand> > commandHandlerMock = CreateCommandHandlerMockWithoutResult <TestCommand>(aggregateException); ICommandBus sut = CreateSut(CreateCommandHandlerMockCollection(commandHandlerMock.Object)); IntranetCommandBusException result = Assert.ThrowsAsync <IntranetCommandBusException>(async() => await sut.PublishAsync(new TestCommand())); Assert.That(result.InnerException, Is.EqualTo(innerException)); }