public SagaMediatorInitiationsTests()
        {
            var serviceLocator = new DumbServiceLocator();

            repository = new InMemorySagaRepository(new JsonNetSerialiser(), serviceLocator);
            sut        = new SagaMediator(repository, serviceLocator, typeof(SagaMediatorInitiationsTests).Assembly);
        }
        public MetadataPipelineIntegrationTests()
        {
            initialisationTime   = new DateTime(1905, 9, 13);
            TimeProvider.Current = new StubTimeProvider(initialisationTime);

            var container = new TinyIoCContainer();

            container.RegisterSagas(typeof(MetadataPipelineIntegrationTests).Assembly);
            var serviceLocator = new TinyIocSagaFactory(container);


            var jsonNetSerialiser = new JsonNetSerialiser();
            var sagaRepository    = new InMemorySagaRepository(jsonNetSerialiser, serviceLocator);
            var hooks             = new IPipelineHook[] { new MetadataPipelineHook(jsonNetSerialiser) };

            var sagaMediator = new SagaMediator(sagaRepository, serviceLocator, hooks);

            correlationId = Guid.NewGuid();
            var initiatingMessage = new MySagaInitiatingMessage(correlationId);

            sagaMediator.Consume(initiatingMessage);
            var saga = sagaRepository.Find <MySaga>(correlationId);

            sagaMetadata = saga.GetSagaMetadata(new JsonNetSerialiser());
        }
Example #3
0
        public static void Main(params string[] args)
        {
            var serviceLocator = new DumbServiceLocator();

            _sagaRepository = new InMemorySagaRepository(new JsonNetSerialiser(), serviceLocator);
            _sagaMediator   = new SagaMediator(_sagaRepository, serviceLocator, typeof(Program).Assembly);

            var correlationId = Guid.NewGuid();

            StartSaga(correlationId);

            RequestVerificationCode(correlationId);

            ProvideVerificationCode(correlationId);

            CreateAccount(correlationId);

            var saga      = _sagaRepository.Find <AccountCreationSaga>(correlationId);
            var jamesName = saga.SagaData.Person.FullName;

            Console.WriteLine($"Taking information from SagaData; Person.FullName='{jamesName}'");

            // and time to remove saga from the storage
            _sagaRepository.Complete(correlationId);

            Console.WriteLine("Press Any Key");
            Console.ReadKey();
        }
        public SagaMediatorConsumingTests()
        {
            var container = new TinyIoCContainer();

            container.RegisterSagas(typeof(SagaMediatorConsumingTests).Assembly);
            var serviceLocator = new TinyIocSagaFactory(container);

            repository = new InMemorySagaRepository(new JsonNetSerialiser(), serviceLocator);
            sut        = new SagaMediator(repository, serviceLocator, new[] { new NullPipelineHook() });
        }
Example #5
0
        public SagaMediatorPipelineTests()
        {
            var container = new TinyIoCContainer();

            container.RegisterSagas(typeof(SagaMediatorPipelineTests).Assembly);
            var serviceLocator = new TinyIocSagaFactory(container);


            repository   = new InMemorySagaRepository(new JsonNetSerialiser(), serviceLocator);
            pipelineHook = Substitute.For <IPipelineHook>();
            var pipelineHooks = new IPipelineHook[] { pipelineHook };

            sut = new SagaMediator(repository, serviceLocator, pipelineHooks);
        }