//~ Methods //////////////////////////////////////////////////////////////// public override ICollection GetKeys(String prefix, int type) { lock (this) { IList result = new LinkedList(); foreach(String key in Map.Keys){ if ((prefix == null) || key.StartsWith(prefix)) { if (type == 0) { result.Add(key); } else { ValueEntry v = (ValueEntry) Map[key]; if (v.type == type) { result.Add(key); } } } } Collections.Sort(result); return result; } }
public void AddMultipleObjects() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); Assert.IsTrue(ll.Count == 3, "Expected 3 items not " + ll.Count); Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]); Assert.IsTrue(ll[1].Equals("item2"), "Expected second element to be \"item2\" not " + ll[1]); }
public void RuleForCommitOnSubclassOfChecked() { IList list = new LinkedList(); list.Add( new RollbackRuleAttribute("System.Data.DataException")); list.Add( new NoRollbackRuleAttribute("Spring.Transaction.TransactionSystemException")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list ); Assert.IsTrue( rta.RollbackOn(new SystemException())); Assert.IsFalse( rta.RollbackOn(new TransactionSystemException())); }
public void Insert() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Insert(1, "item1andahalf"); Assert.IsTrue(ll.Count == 3, "Expected 3 items not " + ll.Count); Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]); Assert.IsTrue(ll[1].Equals("item1andahalf"), "Expected second element to be \"item1andahalf\" not " + ll[1]); Assert.IsTrue(ll[2].Equals("item2"), "Expected third element to be \"item2\" not " + ll[0]); }
public void RemoveAt() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); ll.RemoveAt(1); Assert.IsTrue(ll.Count == 2, "Expected 2 items not " + ll.Count); Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]); Assert.IsTrue(ll[1].Equals("item3"), "Expected second element to be \"item3\" not " + ll[1]); }
public void RemoveObject() { string item1 = "item1"; string item2 = "item2"; string item3 = "item3"; LinkedList ll = new LinkedList(); ll.Add(item1); ll.Add(item2); ll.Add(item3); ll.Remove(item2); Assert.IsTrue(ll.Count == 2, "Expected 2 items not " + ll.Count); Assert.IsTrue(ll[0].Equals("item1"), "Expected first element to be \"item1\" not " + ll[0]); Assert.IsTrue(ll[1].Equals("item3"), "Expected second element to be \"item3\" not " + ll[1]); }
public void RuleForSelectiveRollbackOnCheckedWithClass() { IList list = new LinkedList(); list.Add( new RollbackRuleAttribute(typeof(TransactionSystemException))); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list ); ruleForSelectionRollbackOnChecked( rta ); }
public void RuleForRollbackOnApplicationException() { IList list = new LinkedList(); list.Add(new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list ); Assert.IsTrue( rta.RollbackOn(new SystemException())); //mlp 3/17 changed rollback to rollback on all exceptions. Assert.IsTrue( rta.RollbackOn(new ApplicationException())); Assert.IsTrue(( rta.RollbackOn( new TransactionSystemException()))); }
public void RollbackNever() { IList list = new LinkedList(); list.Add( new NoRollbackRuleAttribute("System.Exception")); RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list ); Assert.IsFalse(rta.RollbackOn(new SystemException())); Assert.IsFalse(rta.RollbackOn(new DataException())); Assert.IsFalse(rta.RollbackOn(new ApplicationException())); Assert.IsFalse(rta.RollbackOn(new TransactionSystemException())); }
public void CopyToWithNonZeroIndex() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); string[] strings = new string[5]; strings[0] = "string1"; strings[1] = "string2"; ll.CopyTo(strings, 2); Assert.IsTrue(strings[0].Equals("string1"), "Expected first element to be \"string1\" not " + strings[0]); Assert.IsTrue(strings[1].Equals("string2"), "Expected second element to be \"string2\" not " + strings[1]); Assert.IsTrue(strings[2].Equals("item1"), "Expected third element to be \"item1\" not " + strings[2]); Assert.IsTrue(strings[3].Equals("item2"), "Expected fourth element to be \"item2\" not " + strings[3]); Assert.IsTrue(strings[4].Equals("item3"), "Expected fifth element to be \"item3\" not " + strings[4]); }
public void CopyToWithNegativeIndex() { LinkedList ll = new LinkedList(); ll.Add("item1"); string[] strings = new string[1]; ll.CopyTo(strings, -1); }
public void CopyToWithIndexGreaterThanArrayLength() { LinkedList ll = new LinkedList(); ll.Add("item1"); string[] strings = new string[1]; ll.CopyTo(strings, 2); }
public void CopyToWithInsufficientSizeArray() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); string[] strings = new string[2]; ll.CopyTo(strings, 1); }
public void Enumerator() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); IEnumerator ienum = ll.GetEnumerator(); Assert.IsTrue(ienum.MoveNext()); Assert.IsTrue(ienum.Current.Equals("item1"), "Expected first element to be \"item1\" not " + ienum.Current); Assert.IsTrue(ienum.MoveNext()); Assert.IsTrue(ienum.Current.Equals("item2"), "Expected second element to be \"item2\" not " + ienum.Current); }
public void Contains() { LinkedList ll = new LinkedList(); Assert.IsFalse(ll.Contains("Foo")); ll = new LinkedList(); Assert.IsFalse(ll.Contains(null)); ll.Add("Foo"); ll.Add(null); ll.Add("Bar"); Assert.IsTrue(ll.Contains(null)); Assert.IsTrue(ll.Contains("Bar")); Assert.IsTrue(ll.Contains("Foo")); ll = new LinkedList(); ll.Add("Foo"); ll.Add("Bar"); Assert.IsFalse(ll.Contains(null)); }
public void CopyToWithInsufficientSizeArray() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); string[] strings = new string[2]; Assert.Throws<ArgumentException>(() => ll.CopyTo(strings, 1)); }
public void CopyToWithIndexGreaterThanArrayLength() { LinkedList ll = new LinkedList(); ll.Add("item1"); string[] strings = new string[1]; Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, 2)); }
public void CopyToWithNullArray() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.CopyTo(null, 0); }
public void EnumeratorModification() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); IEnumerator ienum = ll.GetEnumerator(); Assert.IsTrue(ienum.MoveNext()); ll.RemoveAt(0); Assert.Throws<InvalidOperationException>(() => ienum.MoveNext()); }
public void CopyToWithZeroIndex() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); string[] strings = new string[3]; ll.CopyTo(strings, 0); Assert.IsTrue(strings[0].Equals("item1"), "Expected first element to be \"item1\" not " + strings[0]); Assert.IsTrue(strings[1].Equals("item2"), "Expected second element to be \"item2\" not " + strings[1]); Assert.IsTrue(strings[2].Equals("item3"), "Expected third element to be \"item3\" not " + strings[2]); }
public void IndexOfObject() { string item1 = "item1"; string item2 = "item2"; string item3 = "item3"; LinkedList ll = new LinkedList(); ll.Add(item1); ll.Add(item2); ll.Add(item3); int index = ll.IndexOf(item2); Assert.IsTrue(index == 1, "Expected index of 1 not " + index); }
public void CopyToWithNullArray() { LinkedList ll = new LinkedList(); ll.Add("item1"); Assert.Throws<ArgumentNullException>(() => ll.CopyTo(null, 0)); }
public void CopyToWithNegativeIndex() { LinkedList ll = new LinkedList(); ll.Add("item1"); string[] strings = new string[1]; Assert.Throws<ArgumentOutOfRangeException>(() => ll.CopyTo(strings, -1)); }
/// <summary> /// Return the transaction attribute, given this set of attributes /// attached to a method or class. Return null if it's not transactional. /// </summary> /// <remarks> /// Protected rather than private as subclasses may want to customize /// how this is done: for example, returning a /// <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> /// affected by the values of other attributes. /// This implementation takes into account /// <see cref="Spring.Transaction.Interceptor.RollbackRuleAttribute"/>s, if /// the TransactionAttribute is a RuleBasedTransactionAttribute. /// </remarks> /// <param name="attributes"> /// Attributes attached to a method or class. May be null, in which case a null /// <see cref="Spring.Transaction.Interceptor.ITransactionAttribute"/> will be returned. /// </param> /// <returns> /// The <see cref="ITransactionAttribute"/> configured transaction attribute, or null /// if none was found. /// </returns> protected virtual ITransactionAttribute FindTransactionAttribute(Attribute[] attributes) { if (null == attributes) { return null; } ITransactionAttribute transactionAttribute = null; foreach (Attribute currentAttribute in attributes) { transactionAttribute = currentAttribute as ITransactionAttribute; if (null != transactionAttribute) { break; } } RuleBasedTransactionAttribute ruleBasedTransactionAttribute = transactionAttribute as RuleBasedTransactionAttribute; if (null != ruleBasedTransactionAttribute) { IList rollbackRules = new LinkedList(); foreach (Attribute currentAttribute in attributes) { RollbackRuleAttribute rollbackRuleAttribute = currentAttribute as RollbackRuleAttribute; if (null != rollbackRuleAttribute) { rollbackRules.Add(rollbackRuleAttribute); } } ruleBasedTransactionAttribute.RollbackRules = rollbackRules; return ruleBasedTransactionAttribute; } return transactionAttribute; }
public void EnumeratorModification() { LinkedList ll = new LinkedList(); ll.Add("item1"); ll.Add("item2"); ll.Add("item3"); IEnumerator ienum = ll.GetEnumerator(); Assert.IsTrue(ienum.MoveNext()); ll.RemoveAt(0); ienum.MoveNext(); Assert.Fail("Expected enumerator to fail with InvalidOperationException"); }