Beispiel #1
0
        public void TestThatJournalAppendsOneEventWithSnapshot()
        {
            var interest = new MockAppendResultInterest <Test1Source, SnapshotState>();

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

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

            _journal.AppendWith(streamName, streamVersion, new Test1Source(), new SnapshotState(), interest, _object);

            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.True(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.True(dispatched.State.IsPresent);
            Assert.NotNull(dispatched.Id);
            var dispatchedEntries = dispatched.Entries;

            Assert.Single(dispatchedEntries);
        }