Exemplo n.º 1
0
        public void TestThatJournalReaderReadsThreeEvents()
        {
            var interest = new MockAppendResultInterest <Test1Source, SnapshotState>();

            _dispatcher.AfterCompleting(1);
            interest.AfterCompleting(1);

            var three = new List <Source <string> > {
                new Test1Source(), new Test2Source(), new Test1Source()
            };

            _journal.AppendAll <Source <string>, SnapshotState>("123", 1, three, interest, _object);

            var accessResults = new TestResults().AfterCompleting(1);

            _journal.JournalReader <TextEntry>("test")
            .AndThenTo(reader => reader.ReadNext(5)
                       .AndThenConsume(entries => {
                accessResults.WriteUsing("addAll", entries.Select(entry => (BaseEntry <string>)entry).ToList());
            }));

            Assert.Equal(3, accessResults.ReadFrom <int>("size"));
            Assert.Equal("1", accessResults.ReadFrom <int, string>("entryId", 0));
            Assert.Equal("2", accessResults.ReadFrom <int, string>("entryId", 1));
            Assert.Equal("3", accessResults.ReadFrom <int, string>("entryId", 2));
        }
Exemplo n.º 2
0
        public void TestThatOneTwoAllEventsProject()
        {
            _accessHolder.AccessJournalFor(1);
            _accessHolder.AccessProjectionFor(5); // One, Two, and All

            _journal.AppendAll <ISource>(StreamName, 1, new List <ISource> {
                new OneHappened(), new TwoHappened(), new ThreeHappened()
            }, _appendInterest, _accessHolder);

            Assert.Equal(1, _accessHolder.AccessJournal.ReadFrom <int>(AccessJournal));
            Assert.True(_accessHolder.AccessProjection.ReadFrom <int>(AccessProjection) >= 5);
        }