public void ShouldThrowWhenNoRegisteredAttributeQueryHandlerIsFound() { var registration = new QueryHandlerAttributeRegistration(); var dispatcher = new LoggingQueryDispatcher(new QueryDispatcher(registration), _outputHelper); const string data = nameof(ShouldThrowWhenNoRegisteredAttributeQueryHandlerIsFound); Func <Task> action = () => { return(dispatcher.DispatchAsync <QuerySomething, string>(new QuerySomething(data))); }; action.Should().Throw <NoQueryHandlerResolvedException>(); }
public void ShouldPropagateExceptionFromQueryHandler() { var queryHandler = new TestQueryHandler(_outputHelper); var registration = new QueryHandlerRegistration(); registration.Register(() => (IQueryAsyncHandler <QuerySomethingWithException, string>)queryHandler); var dispatcher = new LoggingQueryDispatcher(new QueryDispatcher(registration), _outputHelper); Func <Task> action = () => { return(dispatcher.DispatchAsync <QuerySomethingWithException, string>( new QuerySomethingWithException("This will cause an exception."))); }; action.Should().Throw <TestQueryHandlerException>(); }