Inheritance: IEventAggregate
 public void OptimisticLockTest()
 {
     var aggregate = new EventAggregate();
     using (var tran = aggregate.BeginTransaction())
     {
         aggregate.Push(0, "test1");
         aggregate.Push(0, "test2");
     }
 }
 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));
 }
        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());
        }
        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);
        }
 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));
 }
        public void TryGetNextUnsuccessfullTest()
        {
            var aggregate = new EventAggregate();

            object result;
            Assert.IsFalse (aggregate.TryGetNext(0, out result));
        }
        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);
        }
        public void TryGetNextNegativeVersionTest()
        {
            var aggregate = new EventAggregate();

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