コード例 #1
0
ファイル: CqrsEngineTests.cs プロジェクト: ddd-cqrs-es/Cqrs-1
        public void NEventSToreInvestigationTest()
        {
            var log = MockRepository.GenerateMock <ILog>();

            using (var engine = new InMemoryCqrsEngine(
                       LocalBoundedContext.Named("local")
                       .PublishingEvents(typeof(int)).To("events").RoutedTo("events")
                       .ListeningCommands(typeof(string)).On("commands1").RoutedFromSameEndpoint()
                       .ListeningCommands(typeof(DateTime)).On("commands2").RoutedFromSameEndpoint()
                       .WithCommandsHandler <CommandHandler>()
                       .WithProcess <TestProcess>()
                       .WithEventStore(dispatchCommits => Wireup.Init()
                                       .LogTo(type => log)
                                       .UsingInMemoryPersistence()
                                       .InitializeStorageEngine()
                                       .UsingJsonSerialization()
                                       .UsingSynchronousDispatchScheduler()
                                       .DispatchTo(dispatchCommits))
                       ,
                       LocalBoundedContext.Named("projections")
                       .WithProjection <EventsListener>("local"),
                       RemoteBoundedContext.Named("remote", "projections")
                       .ListeningCommands(typeof(object)).On("remoteCommands")
                       .PublishingEvents(typeof(int)).To("remoteEvents"),
                       Saga <TestSaga> .Listening("local", "projections"),
                       Saga.Instance(new TestSaga()).Listening("local", "projections")
                       ))
            {
                /*
                 *                                                              .WithEventSource()
                 *                                                              .WithAggregates()
                 *                                                              .WithDocumentStore());
                 * */

                engine.SendCommand("test", "local");
                engine.SendCommand(DateTime.Now, "local");

                Thread.Sleep(500);
                Console.WriteLine("Disposing...");
            }
            Console.WriteLine("Dispose completed.");
        }