예제 #1
0
 public void SetAndGetValueFromReferenceInNotCommitedTransaction()
 {
     Machine machine = new Machine();
     TransactionalReference reference = new TransactionalReference();
     reference.SetValue("foo");
     Assert.AreEqual("foo", reference.GetValue());
     Transaction transaction = new Transaction(machine);
     Machine.CurrentTransaction = transaction;
     reference.SetValue("bar");
     Assert.AreEqual("bar", reference.GetValue());
     transaction.Dispose();
     Machine.CurrentTransaction = null;
     Assert.AreEqual("foo", reference.GetValue());
     Assert.IsFalse(reference.HasSnapshots);
 }
예제 #2
0
        public void SetAndGetValueUsingTwoTransactions()
        {
            Machine machine = new Machine();
            TransactionalReference reference = new TransactionalReference();
            reference.SetValue("foo");
            Assert.AreEqual("foo", reference.GetValue());

            Transaction transaction1 = new Transaction(machine);
            Transaction transaction2 = new Transaction(machine);

            reference.SetValue("bar", transaction1);
            Assert.AreEqual("foo", reference.GetValue(transaction2));
            Assert.AreEqual("bar", reference.GetValue(transaction1));

            transaction1.Complete();
            transaction1.Dispose();

            Assert.IsTrue(reference.HasSnapshots);

            Assert.AreEqual("bar", reference.GetValue());
            Assert.AreEqual("foo", reference.GetValue(transaction2));

            transaction2.Dispose();

            Assert.IsFalse(reference.HasSnapshots);
        }