Пример #1
0
        public void GetHandledMessageTypes_should_return_handled_messages_types()
        {
            var results = SagaUtils <DummySaga, DummySagaState> .GetHandledMessageTypes();

            results.Should().NotBeNullOrEmpty().And.HaveCount(2);
            results.Should().Contain(new[] { typeof(StartDummySaga), typeof(DummySagaStarted) });
        }
        public static ISagaConfigurator <TS, TD> UseRabbitMQTransport <TS, TD>(this ISagaConfigurator <TS, TD> sagaConfigurator)
            where TS : Saga <TD>
            where TD : SagaState
        {
            var messageTypes = SagaUtils <TS, TD> .GetHandledMessageTypes();

            foreach (var messageType in messageTypes)
            {
                sagaConfigurator.Services.AddBusSubscriber(
                    typeof(RabbitSubscriber <>).MakeGenericType(messageType));
            }

            return(sagaConfigurator);
        }
        public static ISagaConfigurator <TS, TD> UseInMemoryTransport <TS, TD>(this ISagaConfigurator <TS, TD> sagaConfigurator)
            where TS : Saga <TD>
            where TD : SagaState
        {
            var messageTypes = SagaUtils <TS, TD> .GetHandledMessageTypes();

            foreach (var messageType in messageTypes)
            {
                var registerMessageMethod = RawRegisterMessageMethod.MakeGenericMethod(messageType);
                registerMessageMethod.Invoke(null, new[] { sagaConfigurator.Services });
            }

            return(sagaConfigurator);
        }
Пример #4
0
        public static ISagaConfigurator <TS, TD> UseAzureServiceBusTransport <TS, TD>(this ISagaConfigurator <TS, TD> sagaConfigurator)
            where TS : Saga <TD>
            where TD : SagaState
        {
            var messageTypes = SagaUtils <TS, TD> .GetHandledMessageTypes();

            foreach (var messageType in messageTypes)
            {
                sagaConfigurator.Services.AddBusSubscriber(
                    typeof(ServiceBusSubscriber <>).MakeGenericType(messageType));
                sagaConfigurator.Services.AddSingleton(typeof(IInfrastructureCreator),
                                                       typeof(AzureServiceBusInfrastructureCreator <>).MakeGenericType(messageType));
            }

            return(sagaConfigurator);
        }
Пример #5
0
        public void GetHandledMessageTypes_should_return_empty_collection_when_no_messages_handled()
        {
            var results = SagaUtils <EmptySaga, SagaState> .GetHandledMessageTypes();

            results.Should().NotBeNull().And.BeEmpty();
        }