Exemple #1
0
        public async Task with_restart()
        {
            var memory = new MemoryStorageDriver();
            var cache  = new Testing.InMemoryCache();
            var ew     = new EventStreamWrapper <TstEvent, CheckSequence>(
                memory,
                new [] { new CheckSequence.Projection() },
                cache
                );
            await ew.AppendEventsAsync(new[] { new TstEvent(1) });

            await ew.AppendEventsAsync(new[] { new TstEvent(2) });

            await ew.AppendEventsAsync(new[] { new TstEvent(3) });

            await ew.TrySaveAsync();

            await ew.AppendEventsAsync(new[] { new TstEvent(4) });

            await ew.AppendEventsAsync(new[] { new TstEvent(5) });

            Assert.Equal(5u, ew.Current.LastEvt);

            // try to read:
            var ew2 = new EventStreamWrapper <TstEvent, CheckSequence>(
                memory, new[] { new CheckSequence.Projection() },
                cache);

            await ew2.InitializeAsync();

            Assert.Equal(5u, ew2.Current.LastEvt);
        }
Exemple #2
0
 /// <summary> Attempt to save the projection to the cache. </summary>
 public Task TrySaveAsync(CancellationToken cancel = default(CancellationToken)) =>
 Wrapper.TrySaveAsync(cancel);