コード例 #1
0
        public void Basic_memento_restore()
        {
            sut.ApplyEvent(new TestDomainEvent()
            {
                Value = 42
            });
            var memento = sut.GetSnapshot();

            var newSut1 = new TestProjector();

            newSut1.Restore(memento);

            var newSut2 = new TestProjector();

            newSut2.Restore(memento);

            newSut1.ApplyEvent(new TestDomainEvent()
            {
                Value = 1
            });
            Assert.That(newSut1.GetProjection().Sum, Is.EqualTo(43));

            newSut2.ApplyEvent(new TestDomainEvent()
            {
                Value = 2
            });
            Assert.That(newSut2.GetProjection().Sum, Is.EqualTo(44), "State shared instances between events");
        }
コード例 #2
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);
        }
コード例 #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 SetUp()
 {
     sut = new TestProjector();
 }