public void Direct() { CollectionChangedHandler <int> cch; ItemsAddedHandler <int> iah; ItemsRemovedHandler <int> irh; Assert.AreEqual(EventTypeEnum.None, queue.ActiveEvents); queue.CollectionChanged += (cch = new CollectionChangedHandler <int>(queue_CollectionChanged)); Assert.AreEqual(EventTypeEnum.Changed, queue.ActiveEvents); queue.ItemsAdded += (iah = new ItemsAddedHandler <int>(queue_ItemAdded)); Assert.AreEqual(EventTypeEnum.Changed | EventTypeEnum.Added, queue.ActiveEvents); queue.ItemsRemoved += (irh = new ItemsRemovedHandler <int>(queue_ItemRemoved)); Assert.AreEqual(EventTypeEnum.Changed | EventTypeEnum.Added | EventTypeEnum.Removed, queue.ActiveEvents); queue.Add(34); queue.Add(56); queue.AddAll(new int[] { }); queue.Add(34); queue.Add(12); queue.DeleteMax(); queue.DeleteMin(); queue.AddAll(new int[] { 4, 5, 6, 2 }); Assert.AreEqual(17, events.Count); int[] vals = { 34, 0, 56, 0, 34, 0, 12, 0, 56, 0, 12, 0, 4, 5, 6, 2, 0 }; Acts[] acts = { Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Remove, Acts.Changed, Acts.Remove, Acts.Changed, Acts.Add, Acts.Add, Acts.Add, Acts.Add, Acts.Changed }; for (var i = 0; i < vals.Length; i++) { //Console.WriteLine("{0}", events[cell]); Assert.AreEqual(acts[i], events[i].Key, "Action " + i); Assert.AreEqual(vals[i], events[i].Value, "Value " + i); } queue.CollectionChanged -= cch; Assert.AreEqual(EventTypeEnum.Added | EventTypeEnum.Removed, queue.ActiveEvents); queue.ItemsAdded -= iah; Assert.AreEqual(EventTypeEnum.Removed, queue.ActiveEvents); queue.ItemsRemoved -= irh; Assert.AreEqual(EventTypeEnum.None, queue.ActiveEvents); }
public void Direct() { CollectionChangedHandler<int> cch; ItemsAddedHandler<int> iah; ItemsRemovedHandler<int> irh; Assert.AreEqual(EventTypeEnum.None, queue.ActiveEvents); queue.CollectionChanged += (cch = new CollectionChangedHandler<int>(queue_CollectionChanged)); Assert.AreEqual(EventTypeEnum.Changed, queue.ActiveEvents); queue.ItemsAdded += (iah = new ItemsAddedHandler<int>(queue_ItemAdded)); Assert.AreEqual(EventTypeEnum.Changed | EventTypeEnum.Added, queue.ActiveEvents); queue.ItemsRemoved += (irh = new ItemsRemovedHandler<int>(queue_ItemRemoved)); Assert.AreEqual(EventTypeEnum.Changed | EventTypeEnum.Added | EventTypeEnum.Removed, queue.ActiveEvents); queue.Add(34); queue.Add(56); queue.AddAll<int>(new int[] { }); queue.Add(34); queue.Add(12); queue.DeleteMax(); queue.DeleteMin(); queue.AddAll<int>(new int[] { 4, 5, 6, 2 }); Assert.AreEqual(17, events.Count); int[] vals = { 34, 0, 56, 0, 34, 0, 12, 0, 56, 0, 12, 0, 4, 5, 6, 2, 0 }; Acts[] acts = { Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Add, Acts.Changed, Acts.Remove, Acts.Changed, Acts.Remove, Acts.Changed, Acts.Add, Acts.Add, Acts.Add, Acts.Add, Acts.Changed }; for (int i = 0; i < vals.Length; i++) { //Console.WriteLine("{0}", Events[cell]); Assert.AreEqual(acts[i], events[i].Key, "Action " + i); Assert.AreEqual(vals[i], events[i].Value, "Value " + i); } queue.CollectionChanged -= cch; Assert.AreEqual(EventTypeEnum.Added | EventTypeEnum.Removed, queue.ActiveEvents); queue.ItemsAdded -= iah; Assert.AreEqual(EventTypeEnum.Removed, queue.ActiveEvents); queue.ItemsRemoved -= irh; Assert.AreEqual(EventTypeEnum.None, queue.ActiveEvents); }