public void Add_Unprocessed_NotAddedYet() { var list = new DelayedList <object>(); list.Add(new object()); Assert.IsEmpty(list); }
public void Add_Processed_ItemIsAdded() { var list = new DelayedList <object>(); var item = new object(); list.Add(item); list.ProcessPending(); Assert.IsTrue(list.Contains(item)); }
public void Remove_Unprocessed_NotRemovedYet() { var list = new DelayedList <object>(); var item = new object(); list.Add(item); list.ProcessPending(); list.Remove(item); Assert.IsTrue(list.Contains(item)); }
public void AddThenRemove_Processed_NotAdded() { var list = new DelayedList <object>(); var item = new object(); list.Add(item); list.Remove(item); list.ProcessPending(); Assert.IsFalse(list.Contains(item)); }
public void ClearThenAdd_Processed_OnlyAddedItemLeft() { var list = new DelayedList <object>(); var item = new object(); Fill(list, 5); list.ProcessPending(); list.Clear(); list.Add(item); list.ProcessPending(); Assert.AreEqual(1, list.Count); Assert.AreSame(item, list[0]); }
/// <summary> /// Adds a listener for the event with an optional call-order priority. /// </summary> /// <param name="listener">The listener to add.</param> /// <param name="priority">The priority of the listener compared to other listeners. Controls whether the listener is called before or after other listeners.</param> public void AddListener(IEventListener listener, int priority = 0) { _listeners.Add(new PrioritizedItem <IEventListener>(listener, priority)); }