コード例 #1
0
        public void TestThatEntryReaderReadsOne()
        {
            var access = _interest.AfterCompleting <Entity1, Event>(3);

            _dispatcher.AfterCompleting(0);

            _store.Write(Id1, new Entity1(Id1, 10), 1, new List <Source <Event> > {
                new Event1()
            }, _interest);
            _store.Write(Id2, new Entity2(Id2, "20"), 1, new List <Source <Event> > {
                new Event2()
            }, _interest);
            _store.Write(Id3, new Entity1(Id3, 30), 1, new List <Source <Event> > {
                new Event3()
            }, _interest);

            Assert.Equal(new Event1(), access.ReadFrom <object>("sources"));
            Assert.Equal(new Event2(), access.ReadFrom <object>("sources"));
            Assert.Equal(new Event3(), access.ReadFrom <object>("sources"));

            var entry1 = _reader.ReadNext().Await();

            Assert.True(_entryAdapterProvider.AsEntry <Event, IEntry <string> >(new Event1(), Metadata.NullMetadata()).WithId("0").Equals(entry1));
            var entry2 = _reader.ReadNext().Await();

            Assert.True(_entryAdapterProvider.AsEntry <Event, IEntry <string> >(new Event2(), Metadata.NullMetadata()).WithId("1").Equals(entry2));
            var entry3 = _reader.ReadNext().Await();

            Assert.True(_entryAdapterProvider.AsEntry <Event, IEntry <string> >(new Event3(), Metadata.NullMetadata()).WithId("2").Equals(entry3));

            _reader.Rewind();
            Assert.Equal(new List <IEntry <string> > {
                entry1, entry2, entry3
            }, _reader.ReadNext(3).Await());
        }
        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
            });
        }
コード例 #3
0
        public void TestThatStateStoreWritesText()
        {
            var access1 = _interest.AfterCompleting <Entity1, Entity1>(1);

            _dispatcher.AfterCompleting(1);

            var entity = new Entity1("123", 5);

            _store.Write(entity.Id, entity, 1, _interest);

            Assert.Equal(0, access1.ReadFrom <int>("readObjectResultedIn"));
            Assert.Equal(1, access1.ReadFrom <int>("writeObjectResultedIn"));
            Assert.Equal(Result.Success, access1.ReadFrom <Result>("objectWriteResult"));
            Assert.Equal(entity, access1.ReadFrom <Entity1>("objectState"));
        }