コード例 #1
0
        public void can_only_restore_once()
        {
            var rm = new TestSnapShotReadModel(_aggId, GetListener, null);

            // ReSharper disable once AccessToDisposedClosure
            AssertEx.IsOrBecomesTrue(() => rm.Count == 10);
            var state = rm.GetState();

            rm.Dispose();
            //create while forcing double restore
            Assert.Throws <InvalidOperationException>(() => new TestSnapShotReadModel(
                                                          _aggId,
                                                          GetListener,
                                                          state,
                                                          forceDoubleRestoreError: true));
        }
コード例 #2
0
        public void can_snapshot_and_recover_read_model()
        {
            var rm = new TestSnapShotReadModel(_aggId, GetListener, null);

            AssertEx.IsOrBecomesTrue(() => rm.Count == 10);
            AssertEx.IsOrBecomesTrue(() => rm.Sum == 20);
            AppendEvents(1, _conn, _stream, 5);
            AssertEx.IsOrBecomesTrue(() => rm.Count == 11, 1000);
            AssertEx.IsOrBecomesTrue(() => rm.Sum == 25);
            var snap = rm.GetState();

            rm.Dispose();
            var rm2 = new TestSnapShotReadModel(_aggId, GetListener, snap);

            AssertEx.IsOrBecomesTrue(() => rm2.Count == 11, 1000);
            AssertEx.IsOrBecomesTrue(() => rm2.Sum == 25);
            AppendEvents(1, _conn, _stream, 5);
            AssertEx.IsOrBecomesTrue(() => rm2.Count == 12, 1000);
            AssertEx.IsOrBecomesTrue(() => rm2.Sum == 30);
        }