public void TM_OutstandingTransactions_FuncTest1() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); target.transactionList.Clear(); target.WriteToFile(); // Write empty list to file to initialize state OutstandingTransactions.OutstandingTransactionsValue rmlist1 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List <string> { "rm1", "rm2" }); OutstandingTransactions.OutstandingTransactionsValue rmlist2 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort, new List <string> { "rm3", "rm4" }); target.UpdateAndFlush("id1", rmlist1); target.UpdateAndFlush("id2", rmlist2); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); Assert.IsTrue(target.transactionList.ContainsKey("id2")); Assert.IsTrue(target.transactionList["id1"].transactionType == OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit); Assert.IsTrue(target.transactionList["id2"].transactionType == OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); Assert.IsTrue(rmlist2.nackRMList.Except(target.transactionList["id2"].nackRMList).Count() == 0); }
public void TM_OutstandingTransactions_FuncTest1() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); target.transactionList.Clear(); target.WriteToFile(); // Write empty list to file to initialize state OutstandingTransactions.OutstandingTransactionsValue rmlist1 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List<string> { "rm1", "rm2" }); OutstandingTransactions.OutstandingTransactionsValue rmlist2 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort, new List<string> { "rm3", "rm4" }); target.UpdateAndFlush("id1", rmlist1); target.UpdateAndFlush("id2", rmlist2); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); Assert.IsTrue(target.transactionList.ContainsKey("id2")); Assert.IsTrue(target.transactionList["id1"].transactionType == OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit); Assert.IsTrue(target.transactionList["id2"].transactionType == OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); Assert.IsTrue(rmlist2.nackRMList.Except(target.transactionList["id2"].nackRMList).Count() == 0); }
public void TM_OutstandingTransactions_FuncTest2() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); target.transactionList.Clear(); target.WriteToFile(); // Write empty list to file to initialize state OutstandingTransactions.OutstandingTransactionsValue rmlist1 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List <string> { "rm1", "rm2" }); OutstandingTransactions.OutstandingTransactionsValue rmlist2 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort, new List <string> { "rm3", "rm4" }); target.UpdateAndFlush("id1", rmlist1); target.UpdateAndFlush("id2", rmlist2); // Assume that id2 is now fully committed, the file will have 2 instances of id2 // after this call target.UpdateAndFlush("id2", null); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); // Make sure id2 does not exist in the transactionList Assert.IsTrue(target.transactionList.ContainsKey("id2") == false); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); // Do a full rewrite, id2 should not exist on the file anymore target.WriteToFile(); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); // Make sure id2 does not exist in the transactionList Assert.IsTrue(target.transactionList.ContainsKey("id2") == false); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); }
public void TM_OutstandingTransactions_FuncTest2() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); target.transactionList.Clear(); target.WriteToFile(); // Write empty list to file to initialize state OutstandingTransactions.OutstandingTransactionsValue rmlist1 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List<string> { "rm1", "rm2" }); OutstandingTransactions.OutstandingTransactionsValue rmlist2 = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort, new List<string> { "rm3", "rm4" }); target.UpdateAndFlush("id1", rmlist1); target.UpdateAndFlush("id2", rmlist2); // Assume that id2 is now fully committed, the file will have 2 instances of id2 // after this call target.UpdateAndFlush("id2", null); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); // Make sure id2 does not exist in the transactionList Assert.IsTrue(target.transactionList.ContainsKey("id2") == false); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); // Do a full rewrite, id2 should not exist on the file anymore target.WriteToFile(); target.ReadFromFile(); Assert.IsTrue(target.transactionList.ContainsKey("id1")); // Make sure id2 does not exist in the transactionList Assert.IsTrue(target.transactionList.ContainsKey("id2") == false); Assert.IsTrue(rmlist1.nackRMList.Except(target.transactionList["id1"].nackRMList).Count() == 0); }