Esempio n. 1
0
        public async Task BaseDispatcher_PublishCommandAsync_Should_Keep_Result_Info()
        {
            var cfgBuilder = new DispatcherConfigurationBuilder();

            cfgBuilder
            .ForCommand <TestResultCommand>()
            .UseBuses(typeof(FakeResultDataBus));

            var dispatcher = new BaseDispatcher(cfgBuilder.Build());

            var result = await dispatcher.DispatchCommandAsync(new TestResultCommand());

            result.Should().BeOfType <Result <string> >();
        }
Esempio n. 2
0
        public async Task BaseDispatcher_PublishCommandAsync_WithResult_Should_Enter_InGoodPath_DependingOfResult()
        {
            var cfgBuilder = new DispatcherConfigurationBuilder();

            cfgBuilder
            .ForCommand <TestCommand>()
            .UseBuses(typeof(FakeFailResultBus), typeof(FakeOkResultBus));

            var dispatcher = new BaseDispatcher(cfgBuilder.Build());

            bool successCalled = false;
            bool failureCalled = false;

            (await dispatcher.DispatchCommandAsync(new TestCommand()))
            .OnSuccess(() => successCalled = true)
            .OnFailure(() => failureCalled = true);

            successCalled.Should().BeFalse();
            failureCalled.Should().BeTrue();
        }