コード例 #1
0
        public void verify_projection_up_to_certain_event()
        {
            var id = new TestEventUnfolderId(Interlocked.Increment(ref progressive));

            using (var stream = _eventStore.OpenStream("BLAH", id.AsString(), 0, Int32.MaxValue))
            {
                CommitOneValue(stream, 1);
                CommitOneValue(stream, 2);
                CommitOneValue(stream, 3);
            }

            var unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, 1);
            var rm       = unfolder.GetProjection();

            Assert.That(rm.Sum, Is.EqualTo(1));
            Assert.That(rm.ListOfInt, Is.EquivalentTo(new[] { 1 }));

            unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, 2);
            rm       = unfolder.GetProjection();
            Assert.That(rm.Sum, Is.EqualTo(3));
            Assert.That(rm.ListOfInt, Is.EquivalentTo(new[] { 1, 2 }));

            unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, 3);
            rm       = unfolder.GetProjection();
            Assert.That(rm.Sum, Is.EqualTo(6));
            Assert.That(rm.ListOfInt, Is.EquivalentTo(new[] { 1, 2, 3 }));
        }
コード例 #2
0
        public void verify_snapshot_usage()
        {
            var id = new TestEventUnfolderId(Interlocked.Increment(ref progressive));

            using (var stream = _eventStore.OpenStream("BLAH", id.AsString(), 0, Int32.MaxValue))
            {
                CommitOneValue(stream, 1);
                CommitOneValue(stream, 2);
            }

            var      unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, 1);
            var      memento  = unfolder.GetSnapshot();
            Snapshot s        = new Snapshot(id.AsString(), 2, memento);

            using (var stream = _eventStore.OpenStream("BLAH", id.AsString(), 0, Int32.MaxValue))
            {
                CommitOneValue(stream, 3);
            }
            _persister.Load(null, 1, null).ReturnsForAnyArgs(s);

            unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, Int32.MaxValue);
            var rm = unfolder.GetProjection();

            Assert.That(rm.Sum, Is.EqualTo(6));
            Assert.That(rm.ListOfInt, Is.EquivalentTo(new[] { 1, 2, 3 }));
        }
コード例 #3
0
        public void verify_snapshot_wrong_version_gets_deleted()
        {
            var id       = new TestEventUnfolderId(1);
            var unfolder = new TestProjector();
            var memento  = (EventUnfolderMemento)unfolder.GetSnapshot();

            memento.Signature = "OTHER"; //change the version of the memento.
            Snapshot s = new Snapshot(id, 2, memento);

            _persister.Load("", 1, "").ReturnsForAnyArgs(s);
            sut.GetById <TestProjector, TestAggregateQueryModel>(id, 200);
            _persister.Received().Clear(id, memento.Version, typeof(TestProjector).Name);
        }
コード例 #4
0
        public void verify_snapshot_check_version()
        {
            var id       = new TestEventUnfolderId(1);
            var unfolder = new TestProjector();
            var memento  = (EventUnfolderMemento)unfolder.GetSnapshot();

            memento.Signature = "OTHER"; //change the version of the memento.
            Snapshot s = new Snapshot(id, 2, memento);

            _persister.Load("", 1, "").ReturnsForAnyArgs(s);
            sut.GetById <TestProjector, TestAggregateQueryModel>(id, 200);
            _eventStore.Received().OpenStream("BLAH", id, 0, 200);
        }
コード例 #5
0
        public void verify_use_snapshot_strategy()
        {
            var id = new TestEventUnfolderId(Interlocked.Increment(ref progressive));

            using (var stream = _eventStore.OpenStream(id.AsString()))
            {
                CommitOneValue(stream, 42);
            }
            TestProjector.ShouldSnapshotReturn = true;
            sut.GetById <TestProjector, TestAggregateQueryModel>(id, Int32.MaxValue);
            TestProjector.ShouldSnapshotReturn = false;
            _persister.Received().Persist(Arg.Any <ISnapshot>(), Arg.Any <String>());
        }
コード例 #6
0
        public void verify_basic_in_memory_projection()
        {
            var id = new TestEventUnfolderId(Interlocked.Increment(ref progressive));

            using (var stream = _eventStore.OpenStream("BLAH", id.AsString(), 0, Int32.MaxValue))
            {
                CommitOneValue(stream, 42);
            }

            var unfolder = sut.GetById <TestProjector, TestAggregateQueryModel>(id, Int32.MaxValue);
            var rm       = unfolder.GetProjection();

            Assert.That(rm.Sum, Is.EqualTo(42));
            Assert.That(rm.ListOfInt, Is.EquivalentTo(new[] { 42 }));
        }