Esempio n. 1
0
        public InMemoryStateStoreEntryReaderActorTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            var testWorld = TestWorld.StartWithDefaults("test-store");
            var world     = testWorld.World;

            _interest   = new MockStateStoreResultInterest();
            _dispatcher = new MockStateStoreDispatcher <IEntry <string>, TextState>(_interest);

            var stateAdapterProvider = new StateAdapterProvider(world);

            _entryAdapterProvider = new EntryAdapterProvider(world);

            stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter());
            // NOTE: No adapter registered for Entity2.class because it will use the default

            _store = world.ActorFor <IStateStore <IEntry <string> > >(typeof(InMemoryStateStoreActor <TextState, IEntry <string> >), _dispatcher);

            var completes = _store.EntryReader("test");

            _reader = completes.Await();

            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1));
            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity2).FullName, typeof(Entity2));
        }
Esempio n. 2
0
        public InMemoryStateStoreTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

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

            _world = testWorld.World;

            _interest   = new MockStateStoreResultInterest();
            _dispatcher = new MockStateStoreDispatcher <TextEntry, TextState>(_interest);

            var stateAdapterProvider = new StateAdapterProvider(_world);

            new EntryAdapterProvider(_world);

            stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter());
            // NOTE: No adapter registered for Entity2.class because it will use the default

            _store = _world.ActorFor <IStateStore <TextEntry> >(typeof(InMemoryStateStoreActor <TextState, TextEntry>), _dispatcher);

            StateTypeStateStoreMap.StateTypeToStoreName(_storeName1, typeof(Entity1));
            StateTypeStateStoreMap.StateTypeToStoreName(_storeName2, typeof(Entity2));
        }
Esempio n. 3
0
        public ProjectionDispatcherTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            World = World.StartWithDefaults("test-store");

            var stateAdapterProvider = new StateAdapterProvider(World);

            stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter());
            new EntryAdapterProvider(World);

            StateTypeStateStoreMap.StateTypeToStoreName(nameof(Entity1), typeof(Entity1));
            StateTypeStateStoreMap.StateTypeToStoreName(nameof(Entity2), typeof(Entity2));

            var dispatcherProtocols =
                World.Stage.ActorFor(
                    new[] { DispatcherInterfaceType, typeof(IProjectionDispatcher) }, ProjectionDispatcherType);

            var dispatchers = Protocols.Two <IDispatcher, IProjectionDispatcher>(dispatcherProtocols);

            Dispatcher           = dispatchers._1;
            ProjectionDispatcher = dispatchers._2;

            var storeProtocols =
                World.ActorFor(
                    new[] { StateStoreInterfaceType, typeof(IDispatcherControl) },
                    typeof(InMemoryStateStoreActor <TextState>), Dispatcher);

            var storeWithControl = Protocols.Two <IStateStore, IDispatcherControl>(storeProtocols);

            Store             = storeWithControl._1;
            DispatcherControl = storeWithControl._2;
        }
        public InMemoryStateStoreRedispatchControlTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

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

            _interest = new MockStateStoreResultInterest();
            _interest.AfterCompleting <string, Entity1>(0);
            _dispatcher = new MockStateStoreDispatcher <TextState>(_interest);

            var stateAdapterProvider = new StateAdapterProvider(_world);

            new EntryAdapterProvider(_world);

            stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter());
            // NOTE: No adapter registered for Entity2.class because it will use the default

            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1));

            _store = _world.ActorFor <IStateStore>(typeof(InMemoryStateStoreActor <TextState>), new List <IDispatcher> {
                _dispatcher
            });
        }
Esempio n. 5
0
        public StatefulEntityTest(ITestOutputHelper output)
        {
            var converter = new Converter(output);

            Console.SetOut(converter);

            _world      = World.StartWithDefaults("stateful-entity");
            _dispatcher = new MockTextDispatcher();

            _stateAdapterProvider = new StateAdapterProvider(_world);
            _stateAdapterProvider.RegisterAdapter(new Entity1StateAdapter());
            new EntryAdapterProvider(_world);
            var registry = new StatefulTypeRegistry(_world);

            var store = _world.ActorFor <IStateStore>(() => new InMemoryStateStoreActor <TextState>(new List <IDispatcher> {
                _dispatcher
            }));

            registry.Register(new Info(store, typeof(Entity1State), nameof(Entity1State)));
        }
Esempio n. 6
0
 /// <summary>
 /// Answer myself after registering the <paramref name="adapter"/>.
 /// </summary>
 /// <param name="adapter"><see cref="IStateAdapter{TSource,TEntry}"/> to register</param>
 /// <typeparam name="TSource">The <see cref="Source{T}"/> extender being registered</typeparam>
 /// <typeparam name="TState">The <see cref="State{T}"/> extender being registered</typeparam>
 /// <returns><see cref="Info"/></returns>
 public Info RegisterStateAdapter <TSource, TState>(IStateAdapter <Source <TSource>, State <TState> > adapter)
 {
     StateAdapterProvider.RegisterAdapter(adapter);
     return(this);
 }
Esempio n. 7
0
 /// <summary>
 /// Answer myself after registering the <paramref name="adapter"/>.
 /// </summary>
 /// <param name="adapter"><see cref="IStateAdapter{TSource,TEntry}"/> to register</param>
 /// <param name="consumer">The consumer being registered</param>
 /// <typeparam name="TSource">The <see cref="Source{T}"/> extender being registered</typeparam>
 /// <typeparam name="TState">The <see cref="State{T}"/> extender being registered</typeparam>
 /// <returns><see cref="Info"/></returns>
 public Info RegisterStateAdapter <TSource, TState>(IStateAdapter <Source <TSource>, State <TState> > adapter, Action <Type, IStateAdapter <Source <TSource>, State <TState> > > consumer)
 {
     StateAdapterProvider.RegisterAdapter(adapter, consumer);
     return(this);
 }