public void AddRangeOfElementsWhileEnumerating() { foreach (int num in list) { if (num == 5) { list.AddRange(new[] { 2, 2, 2 }); } } Assert.IsTrue(list.Contains(2)); Assert.IsFalse(list.Contains(4)); Assert.AreEqual(6, list.Count); }
/// <summary> /// Returns true if Program.XenConnections contains the given connection, taking the ConnectionsLock across /// the check. /// </summary> public static bool XenConnectionsContains(IXenConnection connection) { lock (ConnectionsLock) { return(XenConnections.Contains(connection)); } }