예제 #1
0
        public EventSourcedTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            var testWorld = TestWorld.StartWithDefaults("test-es");

            _world = testWorld.World;

            _dispatcher = new MockJournalDispatcher();

            var entryAdapterProvider = EntryAdapterProvider.Instance(_world);

            entryAdapterProvider.RegisterAdapter(new Test1HappenedAdapter());
            entryAdapterProvider.RegisterAdapter(new Test2HappenedAdapter());
            entryAdapterProvider.RegisterAdapter(new Test3HappenedAdapter());

            var journal = _world.ActorFor <IJournal <string> >(() => new InMemoryJournalActor <string>(_dispatcher));

            var registry = new SourcedTypeRegistry(_world);

            registry.Register(Info.RegisterSourced <TestEventSourcedEntity>(journal));
            registry.Register(Info.RegisterSourced <ProductEntity>(journal));
            registry.Register(Info.RegisterSourced <ProductParent>(journal));
            registry.Register(Info.RegisterSourced <ProductGrandparent>(journal));

            _result = new Result();
            _entity = _world.ActorFor <IEntity>(() => new TestEventSourcedEntity(_result));
        }
예제 #2
0
        public CommandSourcedTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world = World.StartWithDefaults("test-cs");

            _dispatcher = new MockJournalDispatcher();

            _journal = _world.ActorFor <IJournal <string> >(() => new InMemoryJournalActor <string>(_dispatcher));

            _registry = new SourcedTypeRegistry(_world);
            _registry.Register(Info.RegisterSourced <TestCommandSourcedEntity>(_journal));
            _registry.Info <TestCommandSourcedEntity>()
            ?.RegisterEntryAdapter(new DoCommand1Adapter())
            .RegisterEntryAdapter(new DoCommand2Adapter())
            .RegisterEntryAdapter(new DoCommand3Adapter());

            _result = new Result();
            _entity = _world.ActorFor <IEntity>(() => new TestCommandSourcedEntity(_result));
        }