public static SagaTestHarness <T> Saga <T>(this BusTestHarness harness)
            where T : class, ISaga
        {
            var repository = new InMemorySagaRepository <T>();

            return(new SagaTestHarness <T>(harness, repository));
        }
Example #2
0
        public static SagaTestHarness <T> Saga <T>(this BusTestHarness harness, string queueName = null)
            where T : class, ISaga
        {
            var repository = new InMemorySagaRepository <T>();

            return(new SagaTestHarness <T>(harness, repository, queueName));
        }
        public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness)
            where T : class, IConsumer, new()
        {
            var consumerFactory = new DefaultConstructorConsumerFactory <T>();

            return(new ConsumerTestHarness <T>(harness, consumerFactory));
        }
        public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness, Action <IConsumerConfigurator <T> > configure,
                                                           string queueName = null)
            where T : class, IConsumer, new()
        {
            var consumerFactory = new DefaultConstructorConsumerFactory <T>();

            return(new ConsumerTestHarness <T>(harness, consumerFactory, configure, queueName));
        }
        public ConsumerTestHarness(BusTestHarness testHarness, IConsumerFactory <TConsumer> consumerFactory)
        {
            _consumerFactory = consumerFactory;

            _consumed = new ReceivedMessageList(testHarness.TestTimeout);

            testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
        }
Example #6
0
        public SagaTestHarnessRegistration(BusTestHarness testHarness)
        {
            TestTimeout = testHarness.TestTimeout;

            Consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken);
            Created  = new SagaList <TSaga>(testHarness.TestTimeout, testHarness.InactivityToken);
            Sagas    = new SagaList <TSaga>(testHarness.TestTimeout, testHarness.InactivityToken);
        }
        public HandlerTestHarness(BusTestHarness testHarness, MessageHandler <TMessage> handler)
        {
            _handler = handler;

            _consumed = new ReceivedMessageList <TMessage>(testHarness.TestTimeout, testHarness.InactivityToken);

            testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
        }
Example #8
0
        public static SagaTestHarness <T> Saga <T>(this BusTestHarness harness, ISagaRepository <T> repository, string queueName = null)
            where T : class, ISaga
        {
            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            return(new SagaTestHarness <T>(harness, repository, queueName));
        }
 public ConsumerTestHarness(BusTestHarness testHarness, IConsumerFactory <TConsumer> consumerFactory, string queueName)
     : this(testHarness, consumerFactory)
 {
     if (string.IsNullOrWhiteSpace(queueName))
     {
         testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
     }
     else
     {
         testHarness.OnConfigureBus += configurator => ConfigureNamedReceiveEndpoint(configurator, queueName);
     }
 }
        public ExecuteActivityTestHarness(BusTestHarness testHarness, IExecuteActivityFactory <TActivity, TArguments> activityFactory,
                                          Action <IExecuteActivityConfigurator <TActivity, TArguments> > configureExecute)
        {
            _configureExecute = configureExecute;
            _activityFactory  = activityFactory;

            Name = GetActivityName();

            ExecuteQueueName = BuildQueueName("execute");

            testHarness.OnConfigureBus += ConfigureBus;
        }
Example #11
0
        public ConsumerTestHarness(BusTestHarness testHarness, IConsumerFactory <TConsumer> consumerFactory, string queueName)
        {
            _consumerFactory = consumerFactory;

            _consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken);

            if (string.IsNullOrWhiteSpace(queueName))
            {
                testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
            }
            else
            {
                testHarness.OnConfigureBus += configurator => ConfigureNamedReceiveEndpoint(configurator, queueName);
            }
        }
Example #12
0
        public SagaTestHarness(BusTestHarness testHarness, ISagaRepository <TSaga> repository)
        {
            _repository          = repository;
            _querySagaRepository = _repository as IQuerySagaRepository <TSaga>;

            _testTimeout = testHarness.TestTimeout;

            _consumed = new ReceivedMessageList(testHarness.TestTimeout);
            _created  = new SagaList <TSaga>(testHarness.TestTimeout);
            _sagas    = new SagaList <TSaga>(testHarness.TestTimeout);

            TestRepository = new TestSagaRepositoryDecorator <TSaga>(_repository, _consumed, _created, _sagas);

            testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
        }
Example #13
0
        public SagaTestHarness(BusTestHarness testHarness, ISagaRepository <TSaga> repository, string queueName)
            : base(repository, testHarness.TestTimeout)
        {
            _consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken);
            _created  = new SagaList <TSaga>(testHarness.TestTimeout, testHarness.InactivityToken);
            _sagas    = new SagaList <TSaga>(testHarness.TestTimeout, testHarness.InactivityToken);

            TestRepository = new TestSagaRepositoryDecorator <TSaga>(repository, _consumed, _created, _sagas);

            if (string.IsNullOrWhiteSpace(queueName))
            {
                testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
            }
            else
            {
                testHarness.OnConfigureBus += configurator => ConfigureNamedReceiveEndpoint(configurator, queueName);
            }
        }
Example #14
0
        public SagaTestHarness(BusTestHarness testHarness, ISagaRepository <TSaga> repository, string queueName)
        {
            _repository          = repository;
            _querySagaRepository = _repository as IQuerySagaRepository <TSaga>;

            _testTimeout = testHarness.TestTimeout;

            _consumed = new ReceivedMessageList(testHarness.TestTimeout);
            _created  = new SagaList <TSaga>(testHarness.TestTimeout);
            _sagas    = new SagaList <TSaga>(testHarness.TestTimeout);

            TestRepository = new TestSagaRepositoryDecorator <TSaga>(_repository, _consumed, _created, _sagas);

            if (string.IsNullOrWhiteSpace(queueName))
            {
                testHarness.OnConfigureReceiveEndpoint += ConfigureReceiveEndpoint;
            }
            else
            {
                testHarness.OnConfigureBus += configurator => ConfigureNamedReceiveEndpoint(configurator, queueName);
            }
        }
        /// <summary>
        /// Creates an execute-only activity test harness
        /// </summary>
        /// <typeparam name="TActivity"></typeparam>
        /// <typeparam name="TArguments"></typeparam>
        /// <param name="harness"></param>
        /// <param name="executeFactoryMethod"></param>
        /// <returns></returns>
        public static ExecuteActivityTestHarness <TActivity, TArguments> ExecuteActivity <TActivity, TArguments>(this BusTestHarness harness,
                                                                                                                 Func <TArguments, TActivity> executeFactoryMethod)
            where TActivity : class, ExecuteActivity <TArguments>
            where TArguments : class
        {
            var activityFactory = new FactoryMethodExecuteActivityFactory <TActivity, TArguments>(executeFactoryMethod);

            return(new ExecuteActivityTestHarness <TActivity, TArguments>(harness, activityFactory, x =>
            {
            }));
        }
        /// <summary>
        /// Creates an activity test harness
        /// </summary>
        /// <typeparam name="TActivity"></typeparam>
        /// <typeparam name="TArguments"></typeparam>
        /// <typeparam name="TLog"></typeparam>
        /// <param name="harness"></param>
        /// <param name="executeFactoryMethod"></param>
        /// <param name="compensateFactoryMethod"></param>
        /// <returns></returns>
        public static ActivityTestHarness <TActivity, TArguments, TLog> Activity <TActivity, TArguments, TLog>(this BusTestHarness harness,
                                                                                                               Func <TArguments, TActivity> executeFactoryMethod, Func <TLog, TActivity> compensateFactoryMethod)
            where TActivity : class, Activity <TArguments, TLog>
            where TArguments : class
            where TLog : class
        {
            var activityFactory = new FactoryMethodActivityFactory <TActivity, TArguments, TLog>(executeFactoryMethod, compensateFactoryMethod);

            return(new ActivityTestHarness <TActivity, TArguments, TLog>(harness, activityFactory, x =>
            {
            }, x =>
            {
            }));
        }
        /// <summary>
        /// Creates an execute-only activity test harness
        /// </summary>
        /// <typeparam name="TActivity"></typeparam>
        /// <typeparam name="TArguments"></typeparam>
        /// <param name="harness"></param>
        /// <returns></returns>
        public static ExecuteActivityTestHarness <TActivity, TArguments> ExecuteActivity <TActivity, TArguments>(this BusTestHarness harness)
            where TActivity : class, ExecuteActivity <TArguments>, new()
            where TArguments : class
        {
            var activityFactory = new FactoryMethodExecuteActivityFactory <TActivity, TArguments>(x => new TActivity());

            return(new ExecuteActivityTestHarness <TActivity, TArguments>(harness, activityFactory, x =>
            {
            }));
        }
 public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness, Func <T> consumerFactoryMethod)
     where T : class, IConsumer
 {
     return(new ConsumerTestHarness <T>(harness, new DelegateConsumerFactory <T>(consumerFactoryMethod)));
 }
        /// <summary>
        /// Creates an activity test harness
        /// </summary>
        /// <typeparam name="TActivity"></typeparam>
        /// <typeparam name="TArguments"></typeparam>
        /// <typeparam name="TLog"></typeparam>
        /// <param name="harness"></param>
        /// <returns></returns>
        public static ActivityTestHarness <TActivity, TArguments, TLog> Activity <TActivity, TArguments, TLog>(this BusTestHarness harness)
            where TActivity : class, Activity <TArguments, TLog>, new()
            where TArguments : class
            where TLog : class
        {
            var activityFactory = new FactoryMethodActivityFactory <TActivity, TArguments, TLog>(x => new TActivity(), x => new TActivity());

            return(new ActivityTestHarness <TActivity, TArguments, TLog>(harness, activityFactory, x =>
            {
            }, x =>
            {
            }));
        }
Example #20
0
        public static StateMachineSagaTestHarness <TInstance, TStateMachine> StateMachineSaga <TInstance, TStateMachine>(this BusTestHarness harness,
                                                                                                                         TStateMachine stateMachine)
            where TInstance : class, SagaStateMachineInstance
            where TStateMachine : SagaStateMachine <TInstance>
        {
            if (stateMachine == null)
            {
                throw new ArgumentNullException(nameof(stateMachine));
            }
            var repository = new InMemorySagaRepository <TInstance>();

            return(new StateMachineSagaTestHarness <TInstance, TStateMachine>(harness, repository, stateMachine));
        }
 public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness, IConsumerFactory <T> consumerFactory)
     where T : class, IConsumer, new()
 {
     return(new ConsumerTestHarness <T>(harness, consumerFactory));
 }
 public ConsumerTestHarness(BusTestHarness testHarness, IConsumerFactory <TConsumer> consumerFactory,
                            Action <IConsumerConfigurator <TConsumer> > configure)
     : this(testHarness, consumerFactory)
 {
     _configure = configure;
 }
        public ConsumerTestHarness(BusTestHarness testHarness, IConsumerFactory <TConsumer> consumerFactory)
        {
            _consumerFactory = consumerFactory;

            _consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken);
        }
        public static StateMachineSagaTestHarness <TInstance, TStateMachine> StateMachineSaga <TInstance, TStateMachine>(this BusTestHarness harness,
                                                                                                                         TStateMachine stateMachine, ISagaRepository <TInstance> repository, string queueName = null)
            where TInstance : class, SagaStateMachineInstance
            where TStateMachine : SagaStateMachine <TInstance>
        {
            if (stateMachine == null)
            {
                throw new ArgumentNullException(nameof(stateMachine));
            }

            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            return(new StateMachineSagaTestHarness <TInstance, TStateMachine>(harness, repository, stateMachine, queueName));
        }
Example #25
0
 public static HandlerTestHarness <T> Handler <T>(this BusTestHarness harness, MessageHandler <T> handler)
     where T : class
 {
     return(new HandlerTestHarness <T>(harness, handler));
 }
Example #26
0
 public static HandlerTestHarness <T> Handler <T>(this BusTestHarness harness)
     where T : class
 {
     return(new HandlerTestHarness <T>(harness, context => TaskUtil.Completed));
 }
 public StateMachineSagaTestHarness(BusTestHarness testHarness, ISagaRepository <TInstance> repository, TStateMachine stateMachine, string queueName)
     : base(testHarness, repository, queueName)
 {
     _stateMachine = stateMachine;
 }
 public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness, IConsumerFactory <T> consumerFactory, string queueName = null)
     where T : class, IConsumer, new()
 {
     return(new ConsumerTestHarness <T>(harness, consumerFactory, queueName));
 }
 public static ConsumerTestHarness <T> Consumer <T>(this BusTestHarness harness, Func <T> consumerFactoryMethod, string queueName = null)
     where T : class, IConsumer
 {
     return(new ConsumerTestHarness <T>(harness, new DelegateConsumerFactory <T>(consumerFactoryMethod), queueName));
 }
Example #30
0
 public ConsumerTestHarnessRegistration(BusTestHarness testHarness)
 {
     Consumed = new ReceivedMessageList(testHarness.TestTimeout, testHarness.InactivityToken);
 }