public void QueryAsync_WhenCalledWithUnsupportedQueryType_ThrowsIntranetQueryBusException() { IQueryBus sut = CreateSut(new List <IQueryHandler>(0)); Mock <IQuery> commandMock = new Mock <IQuery>(); IntranetQueryBusException result = Assert.ThrowsAsync <IntranetQueryBusException>(async() => await sut.QueryAsync <IQuery, object>(commandMock.Object)); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.NoQueryHandlerSupportingQuery)); }
public void QueryAsync_WhenSupportingQueryHandlerThrowsException_ThrowsIntranetQueryBusExceptionWithCorrectInnerException() { Exception exception = _fixture.Create <Exception>(); Mock <IQueryHandler <TestQuery, object> > queryHandlerMock = CreateQueryHandlerMock <TestQuery, object>(_fixture.Create <object>(), exception); IQueryBus sut = CreateSut(CreateQueryHandlerMockCollection(queryHandlerMock.Object)); IntranetQueryBusException result = Assert.ThrowsAsync <IntranetQueryBusException>(async() => await sut.QueryAsync <TestQuery, object>(new TestQuery())); Assert.That(result.InnerException, Is.EqualTo(exception)); }
public void QueryAsync_WhenSupportingQueryHandlerThrowsAggregateExceptionWhereInnerExceptionIsNotIntranetExceptionBase_ThrowsIntranetQueryBusExceptionWithCorrectErrorCode() { AggregateException aggregateException = new AggregateException(_fixture.Create <Exception>()); Mock <IQueryHandler <TestQuery, object> > queryHandlerMock = CreateQueryHandlerMock <TestQuery, object>(_fixture.Create <object>(), aggregateException); IQueryBus sut = CreateSut(CreateQueryHandlerMockCollection(queryHandlerMock.Object)); IntranetQueryBusException result = Assert.ThrowsAsync <IntranetQueryBusException>(async() => await sut.QueryAsync <TestQuery, object>(new TestQuery())); Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ErrorWhileQueryingQuery)); }