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);
        }
        public void SetAndGetValueFromReferenceOutOfTransaction()
        {
            TransactionalReference reference = new TransactionalReference();

            Assert.IsNull(reference.GetValue());
            reference.SetValue("foo");
            Assert.AreEqual("foo", reference.GetValue());
            Assert.IsFalse(reference.HasSnapshots);
        }
        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);
        }
        public void RaiseIfSetValueFromTwoTransactions()
        {
            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);
            reference.SetValue("newbar", transaction2);
            transaction1.Complete();
            transaction2.Complete();
        }