public void TestRedispatch()
        {
            var accessDispatcher = _dispatcher.AfterCompleting(3);

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

            accessDispatcher.WriteUsing("processDispatch", false);
            _store.Write(entity.Id, entity, 1, _interest);

            try
            {
                Thread.Sleep(3000);
            }
            catch
            {
                // ignore
            }

            accessDispatcher.WriteUsing("processDispatch", true);

            accessDispatcher.ReadFromExpecting("dispatchedStateCount", 1);

            var dispatchedStateCount = accessDispatcher.ReadFrom <int>("dispatchedStateCount");

            Assert.True(dispatchedStateCount == 1, "dispatchedStateCount");

            var dispatchAttemptCount = accessDispatcher.ReadFrom <int>("dispatchAttemptCount");

            Assert.True(dispatchAttemptCount > 1, "dispatchAttemptCount");
        }
Example #2
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());
        }
Example #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"));
        }