public void ShouldAllowAttributeQueryHandlersWithNonReferenceTypeQueryResults()
            {
                var queryHandler = new TestAttributedQueryHandler(_outputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                var dispatcher = new QueryDispatcher(registration);
                var result     = dispatcher.Dispatch <QuerySomethingWithNonReferenceTypeResult, int>(new QuerySomethingWithNonReferenceTypeResult(1973));

                result.Should().Be(1973);
            }
            public void Should_Allow_Attribute_Query_Handlers_With_Non_Reference_Type_Query_Results()
            {
                var queryHandler = new TestAttributedQueryHandler(_testOutputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                var dispatcher = new QueryDispatcher(registration);
                var result     = dispatcher.Dispatch <QuerySomethingWithNonReferenceTypeResult, int>(new QuerySomethingWithNonReferenceTypeResult(1973));

                Assert.Equal(1973, result);
            }
            public void ShouldInvokeRegisteredAttributeQueryHandler()
            {
                var queryHandler = new TestAttributedQueryHandler(_outputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                const string data = nameof(ShouldInvokeRegisteredAttributeQueryHandler);

                var dispatcher = new QueryDispatcher(registration);
                var result     = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data));

                result.Should().Be(data);
            }
            public void Should_Invoke_Registered_Attribute_Query_Handler()
            {
                var queryHandler = new TestAttributedQueryHandler(_testOutputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                const string data = nameof(Should_Invoke_Registered_Attribute_Query_Handler);

                var dispatcher = new QueryDispatcher(registration);
                var result     = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data));

                Assert.Equal(result, data);
            }
            public async Task ShouldInvokeRegisteredAttributeQueryHandlerWithCancellationToken()
            {
                var queryHandler = new TestAttributedQueryHandler(_outputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);
                var dispatcher = new QueryDispatcher(registration);

                var          cts  = new CancellationTokenSource();
                const string data = nameof(ShouldInvokeRegisteredAttributeQueryHandlerWithCancellationToken);

                var result = await dispatcher.DispatchAsync <QuerySomethingWithDelay, string>(new QuerySomethingWithDelay(data, 500), cts.Token);

                result.Should().Be(data);
            }
            public async Task Should_Invoke_Registered_Attribute_Query_Handler_With_Cancellation_Token()
            {
                var queryHandler = new TestAttributedQueryHandler(_testOutputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);
                var dispatcher = new QueryDispatcher(registration);

                var          cts  = new CancellationTokenSource();
                const string data = nameof(Should_Invoke_Registered_Attribute_Query_Handler_With_Cancellation_Token);

                var result = await dispatcher.DispatchAsync <QuerySomethingWithDelay, string>(new QuerySomethingWithDelay(data, 500), cts.Token);

                Assert.Equal(data, result);
            }
            public void ShouldInvokeRegisteredAttributeQueryHandlerWhenDispatchedMultipleTimes()
            {
                var queryHandler = new TestAttributedQueryHandler(_outputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                const string data1 = "Test message 1.";
                const string data2 = "Test message 2.";
                const int    data3 = 1;

                var dispatcher = new QueryDispatcher(registration);
                var result1    = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data1));
                var result2    = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data2));
                var result3    = dispatcher.Dispatch <QuerySomethingWithNonReferenceTypeResult, int>(new QuerySomethingWithNonReferenceTypeResult(data3));

                result1.Should().Be(data1);
                result2.Should().Be(data2);
                result3.Should().Be(data3);
            }
            public void Should_Invoke_Registered_Attribute_Query_Handler_When_Dispatched_Multiple_Times()
            {
                var queryHandler = new TestAttributedQueryHandler(_testOutputHelper);
                var registration = new QueryHandlerAttributeRegistration();

                registration.Register(() => queryHandler);

                const string data1 = "Test message 1.";
                const string data2 = "Test message 2.";
                const int    data3 = 1;

                var dispatcher = new QueryDispatcher(registration);
                var result1    = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data1));
                var result2    = dispatcher.Dispatch <QuerySomething, string>(new QuerySomething(data2));
                var result3    = dispatcher.Dispatch <QuerySomethingWithNonReferenceTypeResult, int>(new QuerySomethingWithNonReferenceTypeResult(data3));

                Assert.Equal(data1, result1);
                Assert.Equal(data2, result2);
                Assert.Equal(data3, result3);
            }