Esempio n. 1
0
        public void RecoverTest()
        {
            int siteNumber = 2;
            DataManager target = new DataManager(siteNumber);
            target.Write(2, 5, 1, 1);
            // a different trasnaction reads the original data item
            int actual = target.Read(2, 2);
            Assert.AreEqual(20, actual);

            // the same transaction will read the value it has written
            actual = target.Read(2, 1);
            Assert.AreEqual(5, actual);

            // recover
            target.Recover();

            // same transaction can no longer see the value it ahs written (uncomitted value was lost)
            actual = target.Read(2, 1);
            Assert.AreEqual(20, actual);

            // now write and commit, then recover
            target.Write(2, 5, 1, 1);
            target.CommitAllWrites(new Operation(Enumerations.OperationMode.Commit, 1, ts: 0));
            target.Recover();
            actual = target.Read(2, 1);
            Assert.AreEqual(5, actual);
        }