Beispiel #1
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));
        }
Beispiel #2
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));
        }
Beispiel #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
            });
        }
Beispiel #5
0
        public void TestNonExistingMappings()
        {
            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1));
            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity2).FullName, typeof(Entity2));

            Assert.Null(StateTypeStateStoreMap.StoreNameFrom("123"));
            Assert.Null(StateTypeStateStoreMap.StoreNameFrom(typeof(string).FullName));
        }
Beispiel #6
0
        public void TestExistingMappings()
        {
            StateTypeStateStoreMap.StateTypeToStoreName(typeof(Entity1).FullName, typeof(Entity1));

            Assert.Equal(typeof(Entity1).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity1)));
            Assert.Equal(typeof(Entity1).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity1).FullName));

            Assert.Null(StateTypeStateStoreMap.StoreNameFrom(typeof(Entity2)));
            Assert.Null(StateTypeStateStoreMap.StoreNameFrom(typeof(Entity2).FullName));

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

            Assert.Equal(typeof(Entity2).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity2)));
            Assert.Equal(typeof(Entity2).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity2).FullName));

            Assert.Equal(typeof(Entity1).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity1)));
            Assert.Equal(typeof(Entity1).FullName, StateTypeStateStoreMap.StoreNameFrom(typeof(Entity1).FullName));
        }
Beispiel #7
0
 public StateTypeStateStoreMapTest()
 {
     StateTypeStateStoreMap.Reset();
 }
Beispiel #8
0
 /// <summary>
 /// Answer myself after registering the <see cref="Info{T}"/>.
 /// </summary>
 /// <param name="info"><see cref="Info{T}"/> to register</param>
 /// <returns>The registry</returns>
 public StatefulTypeRegistry Register(Info info)
 {
     StateTypeStateStoreMap.StateTypeToStoreName(info.StoreName, info.StoreType);
     _stores.AddOrUpdate(info.StoreType, info, (type, o) => info);
     return(this);
 }