Inheritance: IEventAggregate
Ejemplo n.º 1
0
 public void OptimisticLockTest()
 {
     var aggregate = new EventAggregate();
     using (var tran = aggregate.BeginTransaction())
     {
         aggregate.Push(0, "test1");
         aggregate.Push(0, "test2");
     }
 }
Ejemplo n.º 2
0
 public void GetRangeTest([Values(0, 1)]int version, [Values(0, 1)]int count)
 {
     var aggregate = new EventAggregate();
     var events = new[] { "a", "b", "c" };
     using (var tran = aggregate.BeginTransaction())
     {
         aggregate.PushMany(-1, events);
         tran.Commit();
     }
     CollectionAssert.AreEqual(events.ToList().GetRange(version, count), aggregate.GetRange(version, count));
 }
Ejemplo n.º 3
0
        public void GetAllNextSuccessfullTest(int count, int startingFrom)
        {
            var aggregate = new EventAggregate();

            using (var tran = aggregate.BeginTransaction())
            {
                for (int i = 0; i < count; i++)
                {
                    aggregate.Push(i, "test" + i);
                }
                tran.Commit();
            }

            var result = aggregate.GetAllNext(startingFrom);
            Assert.AreEqual(count - startingFrom - 1, result.Count());
        }
Ejemplo n.º 4
0
        public void CommitTest()
        {
            var tranCounter = ServerClass.TransactionCounter;
            var aggregate = new EventAggregate();
            Assert.AreEqual(0, aggregate.LastVersion);
            Assert.IsFalse(aggregate.HasUncommitedChanges);

            using (var tran = aggregate.BeginTransaction())
            {
                aggregate.Push(-1, new object());
                Assert.IsTrue(aggregate.HasUncommitedChanges);
                Assert.AreEqual(1, aggregate.LastVersion);

                tran.Commit();
            }

            Assert.IsFalse(aggregate.HasUncommitedChanges);
            Assert.AreEqual(tranCounter + 1, ServerClass.TransactionCounter);
            Assert.AreEqual(1, aggregate.LastVersion);
        }
Ejemplo n.º 5
0
 public void PushManyTest()
 {
     var aggregate = new EventAggregate();
     var events = new[] {"a", "b", "c"};
     using (var tran = aggregate.BeginTransaction())
     {
         aggregate.PushMany(-1, events);
         tran.Commit();
     }
     CollectionAssert.AreEqual(events, aggregate.GetRange(0, 3));
 }
Ejemplo n.º 6
0
        public void TryGetNextUnsuccessfullTest()
        {
            var aggregate = new EventAggregate();

            object result;
            Assert.IsFalse (aggregate.TryGetNext(0, out result));
        }
Ejemplo n.º 7
0
        public void TryGetNextSuccessfullTest()
        {
            var aggregate = new EventAggregate();
            using (var tran = aggregate.BeginTransaction())
            {
                aggregate.Push(0, "test");
                tran.Commit();
            }

            object result;
            Assert.IsTrue(aggregate.TryGetNext(0, out result));
            Assert.AreEqual("test", result);
        }
Ejemplo n.º 8
0
        public void TryGetNextNegativeVersionTest()
        {
            var aggregate = new EventAggregate();

            object result;
            Assert.IsFalse (aggregate.TryGetNext(-1, out result));
        }
Ejemplo n.º 9
0
 public Transaction(EventAggregate aggregate)
 {
     m_Aggregate = aggregate;
 }