public void ProcessNewInputTest()
        {
            using (StreamWriter writer = new StreamWriter("outputFromUnitTestInstance.txt"))
            {

                TransactionManager target = new TransactionManager(writer);

                string inputString = "begin(T1)";
                List<Operation> actual = target.ProcessNewInput(inputString);
                Assert.AreEqual(1, actual.Count);
                Assert.AreEqual(Enumerations.OperationMode.Begin, actual[0].OpMode);
                Assert.AreEqual(1, actual[0].TransactionNumber);
                Assert.AreEqual(-1, actual[0].NewValue);
                Assert.AreEqual(-1, actual[0].DataItem);
                Assert.AreEqual(false, actual[0].ReadOnly);
                Assert.AreEqual(0, actual[0].TimeStamp);

                // test parsing out begin statements
                target.IncrementTimeStamp();
                inputString = "begin(T2);beginRO(T3)";
                actual = target.ProcessNewInput(inputString);
                Assert.AreEqual(2, actual.Count);
                Operation expectedOp = actual[0];
                Assert.AreEqual(Enumerations.OperationMode.Begin, expectedOp.OpMode);
                Assert.AreEqual(2, expectedOp.TransactionNumber);
                Assert.AreEqual(-1, expectedOp.NewValue);
                Assert.AreEqual(-1, expectedOp.DataItem);
                Assert.AreEqual(false, expectedOp.ReadOnly);
                Assert.AreEqual(0, expectedOp.TimeStamp);

                expectedOp = actual[1];
                Assert.AreEqual(Enumerations.OperationMode.Begin, expectedOp.OpMode);
                Assert.AreEqual(3, expectedOp.TransactionNumber);
                Assert.AreEqual(-1, expectedOp.NewValue);
                Assert.AreEqual(-1, expectedOp.DataItem);
                Assert.AreEqual(true, expectedOp.ReadOnly);
                Assert.AreEqual(1, expectedOp.TimeStamp);
                    // because read only transactions have a timestamp set when they begin

                // setup for next test - do not remove because otherwise read/write ops will fail to parse
                foreach (Operation op in actual)
                    if (op.OpMode == Enumerations.OperationMode.Begin)
                        target.activeTransactions[op.TransactionNumber] = new Transaction(op.TransactionNumber,
                                                                                          op.TimeStamp, op.ReadOnly);

                // test parsing out read statements by a regular transaction
                target.IncrementTimeStamp();
                inputString = "begin(T4);beginRO(T5);R(T2, x4)";
                actual = target.ProcessNewInput(inputString);

                Assert.AreEqual(3, actual.Count);
                expectedOp = actual[2];
                Assert.AreEqual(Enumerations.OperationMode.Read, expectedOp.OpMode);
                Assert.AreEqual(2, expectedOp.TransactionNumber);
                Assert.AreEqual(-1, expectedOp.NewValue);
                Assert.AreEqual(4, expectedOp.DataItem);
                Assert.AreEqual(false, expectedOp.ReadOnly);
                Assert.AreEqual(2, expectedOp.TimeStamp);

                // setup for next test - do not remove because otherwise read/write ops will fail to parse
                foreach (Operation op in actual)
                    if (op.OpMode == Enumerations.OperationMode.Begin)
                        target.activeTransactions[op.TransactionNumber] = new Transaction(op.TransactionNumber,
                                                                                          op.TimeStamp, op.ReadOnly);

                // test parsing out read statements by a RO transaction
                target.IncrementTimeStamp();
                inputString = "begin(T6);beginRO(T7);R(T3, x4)";
                actual = target.ProcessNewInput(inputString);
                Assert.AreEqual(3, actual.Count);
                expectedOp = actual[2];
                Assert.AreEqual(Enumerations.OperationMode.Read, expectedOp.OpMode);
                Assert.AreEqual(3, expectedOp.TransactionNumber);
                Assert.AreEqual(-1, expectedOp.NewValue);
                Assert.AreEqual(4, expectedOp.DataItem);
                Assert.AreEqual(true, expectedOp.ReadOnly);
                Assert.AreEqual(1, expectedOp.TimeStamp);
                    // because read only transactions have a timestamp set when they begin

                // setup for next test - do not remove because otherwise read/write ops will fail to parse
                foreach (Operation op in actual)
                    if (op.OpMode == Enumerations.OperationMode.Begin)
                        target.activeTransactions[op.TransactionNumber] = new Transaction(op.TransactionNumber,
                                                                                          op.TimeStamp, op.ReadOnly);

                // test parsing out write statements
                target.IncrementTimeStamp();
                inputString = "begin(T8);R(T2, x4);W(T3, x5, 6)";
                actual = target.ProcessNewInput(inputString);
                Assert.AreEqual(3, actual.Count);
                expectedOp = actual[2];
                Assert.AreEqual(Enumerations.OperationMode.Write, expectedOp.OpMode);
                Assert.AreEqual(3, expectedOp.TransactionNumber);
                Assert.AreEqual(6, expectedOp.NewValue);
                Assert.AreEqual(5, expectedOp.DataItem);
                Assert.AreEqual(false, expectedOp.ReadOnly);
                Assert.AreEqual(4, expectedOp.TimeStamp);

                inputString = "dump()";
                actual = target.ProcessNewInput(inputString);
                inputString = "dump(5)";
                actual = target.ProcessNewInput(inputString);
                inputString = "dump(x5)";
                actual = target.ProcessNewInput(inputString);
            }
        }
        public void ProcessNewOpsTest()
        {
            TransactionManager target = new TransactionManager();
            target.IncrementTimeStamp();
            string inputString = "begin(T1);beginRO(T2)";
            target.ProcessNewOps(inputString);
            Assert.AreEqual(2, target.activeTransactions.Keys.Count);
            Assert.AreEqual(1, target.activeTransactions[1].Id);
            Assert.IsNull(target.activeTransactions[1].CurrentOp);
            Assert.AreEqual(Enumerations.Status.Active, target.activeTransactions[1].CurrentStatus);
            Assert.AreEqual(1, target.activeTransactions[1].TimeStamp);
            Assert.AreEqual(false, target.activeTransactions[1].ReadOnly);
            Assert.IsNull(target.activeTransactions[1].CurrentOp);
            Assert.AreEqual(2, target.activeTransactions[2].Id);
            Assert.IsNull(target.activeTransactions[2].CurrentOp);
            Assert.AreEqual(Enumerations.Status.Active, target.activeTransactions[2].CurrentStatus);
            Assert.AreEqual(1, target.activeTransactions[2].TimeStamp);
            Assert.AreEqual(true, target.activeTransactions[2].ReadOnly);
            Assert.IsNull(target.activeTransactions[2].CurrentOp);

            inputString = "W(T1, x5,6);R(T2, x4)";
            target.ProcessNewOps(inputString);
            Assert.AreEqual(2, target.activeTransactions.Keys.Count);
            Assert.AreEqual(Enumerations.OperationMode.Write, target.activeTransactions[1].CurrentOp.OpMode);
            Assert.AreEqual(1, target.activeTransactions[1].CurrentOp.TransactionNumber);
            Assert.AreEqual(1, target.activeTransactions[1].CurrentOp.TimeStamp);
            Assert.AreEqual(false, target.activeTransactions[1].CurrentOp.ReadOnly);
            Assert.AreEqual(6, target.activeTransactions[1].CurrentOp.NewValue);
            Assert.AreEqual(Enumerations.OperationMode.Read, target.activeTransactions[2].CurrentOp.OpMode);
            Assert.AreEqual(2, target.activeTransactions[2].CurrentOp.TransactionNumber);
            Assert.AreEqual(1, target.activeTransactions[2].CurrentOp.TimeStamp);
            Assert.AreEqual(true, target.activeTransactions[2].CurrentOp.ReadOnly);
            Assert.AreEqual(-1, target.activeTransactions[2].CurrentOp.NewValue);

            target.ProcessNewOps(inputString);
            Assert.AreEqual(2, target.waitingOps.Count);
        }