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_SerializeKeyValueToStringTest3() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); string key = "id"; OutstandingTransactions.OutstandingTransactionsValue value = null; string expected = "id"; string actual; actual = target.SerializeToString(key, value, true); Assert.AreEqual(expected, actual); }
public void TM_OutstandingTransactions_SerializeKeyValueToStringTest1() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); string key = "id"; OutstandingTransactions.OutstandingTransactionsValue value = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List <string> { "rm1", "rm2" }); string expected = "id,0,rm1,rm2"; string actual; actual = target.SerializeToString(key, value); Assert.AreEqual(expected, actual); }
public void TM_OutstandingTransactions_SerializeStringToKeyValueTest2() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); string s = "id,1"; string key; string keyExpected = "id"; OutstandingTransactions.OutstandingTransactionsValue value = null; OutstandingTransactions.OutstandingTransactionsValue valueExpected = new OutstandingTransactions.OutstandingTransactionsValue(); bool expected = true; bool actual; actual = target.SerializeFromString(s, out key, out value); Assert.AreEqual(keyExpected, key); Assert.AreEqual(value.transactionType, OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Abort); Assert.IsTrue(valueExpected.nackRMList.Except(value.nackRMList).Count() == 0); Assert.AreEqual(expected, actual); }
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); }
public void TM_OutstandingTransactions_SerializeKeyValueToStringTest1() { OutstandingTransactions_Accessor target = new OutstandingTransactions_Accessor(); string key = "id"; OutstandingTransactions.OutstandingTransactionsValue value = new OutstandingTransactions.OutstandingTransactionsValue( OutstandingTransactions.OutstandingTransactionsValue.TransactionType.Commit, new List<string> { "rm1", "rm2" }); string expected = "id,0,rm1,rm2"; string actual; actual = target.SerializeToString(key, value); Assert.AreEqual(expected, actual); }