public void Clear_Processed_AllItemsRemoved()
        {
            var list = new DelayedList <object>();

            Fill(list, 5);
            list.ProcessPending();

            list.Clear();
            list.ProcessPending();

            Assert.IsEmpty(list);
        }
        public void Remove_Processed_ItemIsRemoved()
        {
            var list = new DelayedList <object>();
            var item = new object();

            list.Add(item);
            list.ProcessPending();
            list.Remove(item);
            list.ProcessPending();

            Assert.IsFalse(list.Contains(item));
        }
        public void Remove_NotInList_Processed_NothingChanged()
        {
            var list = new DelayedList <object>();
            var item = new object();

            Fill(list, 5);
            list.ProcessPending();
            list.Remove(item);
            list.ProcessPending();

            Assert.AreEqual(5, list.Count);
        }
        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]);
        }
        public void Remove_Empty_Processed_NothingChanged()
        {
            var list = new DelayedList <object>();
            var item = new object();

            list.Remove(item);
            list.ProcessPending();

            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 AddThenClearPending_Processed_NoItemsAdded()
        {
            var list = new DelayedList <object>();

            Fill(list, 5);
            list.ClearPending();
            list.ProcessPending();

            Assert.IsEmpty(list);
        }
        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));
        }
예제 #9
0
        /// <summary>
        /// Notifies all listeners that the event occured.
        /// </summary>
        public void Invoke()
        {
            _listeners.ProcessPending();

            for (var i = 0; i < _listeners.Count; i++)
            {
                // gotta wrap it up so one guy doesn't spoil it for everyone
                try
                {
                    _listeners[i].Item.OnEvent(Id);
                }
                catch (Exception e)
                {
                    Debug.LogError(e);
                }
            }
        }