コード例 #1
0
        public void version_with_snapshot()
        {
            var memento = new Moq.Mock <IMemento>();

            memento.Setup(x => x.EntityId).Returns("test");

            var snapshot = new Moq.Mock <ISnapshot>();

            snapshot.Setup(x => x.Version).Returns(1);
            snapshot.Setup(x => x.Payload).Returns(memento.Object);

            var stream = new Aggregates.Internal.EventStream <Entity>("test", "test", null, null, _events, snapshot.Object);

            Assert.AreEqual(1, stream.StreamVersion);
            Assert.AreEqual(1, stream.CommitVersion);

            stream.Add(new FakeEvent(), new Dictionary <string, string>());

            Assert.AreEqual(2, stream.StreamVersion);
            Assert.AreEqual(1, stream.CommitVersion);

            var uncommitted = stream.Uncommitted.First();

            Assert.AreEqual(2, uncommitted.Descriptor.Version);
        }
コード例 #2
0
        public void dirty_check()
        {
            var stream = new Aggregates.Internal.EventStream <Entity>("test", "test", null, null, _events, null);

            Assert.False(stream.Dirty);

            stream.Add(new FakeEvent(), new Dictionary <string, string>());

            Assert.True(stream.Dirty);
        }
コード例 #3
0
        public void new_stream_version()
        {
            var stream = new Aggregates.Internal.EventStream <Entity>("test", "test", null, null, null, null);

            Assert.AreEqual(-1, stream.CommitVersion);
            Assert.AreEqual(-1, stream.StreamVersion);

            stream.Add(new FakeEvent(), new Dictionary <string, string>());

            Assert.AreEqual(-1, stream.CommitVersion);
            Assert.AreEqual(0, stream.StreamVersion);

            var uncommitted = stream.Uncommitted.First();

            Assert.AreEqual(0, uncommitted.Descriptor.Version);
        }
コード例 #4
0
        public void total_uncomitted()
        {
            var stream = new Aggregates.Internal.EventStream <Entity>("test", "test", null, null, _events, null);

            Assert.AreEqual(0, stream.TotalUncommitted);

            stream.Add(new FakeEvent(), new Dictionary <string, string>());

            Assert.AreEqual(1, stream.TotalUncommitted);

            stream.DefineOob("test");
            stream.AddOob(new FakeEvent(), "test", new Dictionary <string, string>());

            Assert.AreEqual(2, stream.TotalUncommitted);

            var memento = new Moq.Mock <IMemento>();

            stream.AddSnapshot(memento.Object);

            Assert.AreEqual(3, stream.TotalUncommitted);
        }