public void AddAndRemoveWhileEnumerating() { foreach (int num in list) { if (num == 5) { list.Add(7); } else if (num > 1) { list.Remove(num); } } Assert.AreEqual("1, 5, 7", list.ToText()); }
public static void AddAlert(Alert a) { try { lock (XenCenterAlertsLock) XenCenterAlerts.Add(a); } catch (Exception e) { log.Error("Failed to add incoming alert", e); } }
public void TestCloningChangeableList() { foreach (int num1 in list) { Assert.AreEqual(1, num1); list.Add(1); var testList2 = new ChangeableList<int>(list); foreach (int num2 in testList2) { Assert.AreEqual(1, num2); testList2.Add(2); // The lists should be different here (testList2 is cloned) Assert.False(list == testList2); // But the data in it should be still equal. Assert.AreEqual(list.ToText(), testList2.ToText()); break; } break; } }
public void TestCloningChangeableList() { foreach (int num1 in list) { Assert.AreEqual(1, num1); list.Add(1); var testList2 = new ChangeableList <int>(list); foreach (int num2 in testList2) { Assert.AreEqual(1, num2); testList2.Add(2); // The lists should be different here (testList2 is cloned) Assert.False(list == testList2); // But the data in it should be still equal. Assert.AreEqual(list.ToText(), testList2.ToText()); break; } break; } }