Beispiel #1
0
        public void TestThatOneEventProject()
        {
            _accessHolder.AccessJournalFor(1);
            _accessHolder.AccessProjectionFor(2); // One and All

            _journal.Append(StreamName, 1, new OneHappened(), _appendInterest, _accessHolder);

            Assert.Equal(1, _accessHolder.AccessJournal.ReadFrom <int>(AccessJournal));
            Assert.Equal(2, _accessHolder.AccessProjection.ReadFrom <int>(AccessProjection));
        }
Beispiel #2
0
        public void TestThatJournalAppendsOneEvent()
        {
            var interest = new MockAppendResultInterest <Test1Source, SnapshotState>();

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

            var source        = new Test1Source();
            var streamName    = "123";
            var streamVersion = 1;

            _journal.Append <Test1Source, SnapshotState>(streamName, streamVersion, source, interest, _object);

            Assert.Equal(1, interest.ReceivedAppendsSize);

            var entries     = interest.Entries;
            var journalData = entries.First();

            Assert.NotNull(journalData);
            Assert.Equal(streamName, journalData.StreamName);
            Assert.Equal(streamVersion, journalData.StreamVersion);
            Assert.Equal(Result.Success, journalData.Result);
            Assert.False(journalData.Snapshot.IsPresent);

            var sourceList = journalData.Sources;

            Assert.Single(sourceList);
            Assert.Equal(source, sourceList.First());

            Assert.Equal(1, _dispatcher.DispatchedCount());
            var dispatched = _dispatcher.GetDispatched()[0];

            Assert.NotEqual(new DateTimeOffset(), dispatched.CreatedOn);
            Assert.False(dispatched.State.IsPresent);
            Assert.NotNull(dispatched.Id);
            var dispatchedEntries = dispatched.Entries;

            Assert.Single(dispatchedEntries);
        }
        public void TestThatDefaultFeedReadsFirstFeedItemIncomplete()
        {
            var feed = Feed.DefaultFeedWith(_world.Stage, "test", typeof(TextEntryReaderFeeder), _entryReader);

            var dispatcherAccess = _dispatcher.AfterCompleting(3);

            _journal.Append("stream-1", 1, new TestEvents.Event1(), _interest, null);
            _journal.Append("stream-2", 1, new TestEvents.Event2(), _interest, null);
            _journal.Append("stream-3", 1, new TestEvents.Event3(), _interest, null);

            var count = dispatcherAccess.ReadFrom <int>("entriesCount");

            Assert.Equal(3, count);

            var consumerAccess = _consumer.AfterCompleting(1);

            feed.Feeder.FeedItemTo(FeedItemId.With(1), _consumer);

            var feedItems = consumerAccess.ReadFrom <Dictionary <long, FeedItem> >("feedItems");

            Assert.Single(feedItems);
            Assert.False(feedItems[1L].Archived);
        }