public void List_Remove() { var lst = new EventedList <string, string>("CONTEXT", false); var first = true; lst.GetReadOnlyEvent = (_) => false; lst.Add("a"); lst.Add("b"); lst.Add("c"); Aver.AreEqual(3, lst.Count); lst.ChangeEvent = (l, ct, p, idx, v) => { Aver.AreObjectsEqual(EventedList <string, string> .ChangeType.Remove, ct); Aver.AreObjectsEqual(first ? EventPhase.Before : EventPhase.After, p); Aver.AreEqual(-1, idx); Aver.AreEqual("b", v); first = false; }; lst.Remove("b"); Aver.AreEqual(2, lst.Count); }
public void CollectionChangedRemoveDataItemsResultInCollectionChangedForAdapter() { //create a list of dataItem containing urls IEventedList <IDataItem> dataItems = new EventedList <IDataItem>(); var url = new Url(); var dataItem = new DataItem(url); dataItems.Add(dataItem); //adapter for the list var adapter = new DataItemsEventedListAdapter <Url>(dataItems); int callCount = 0; adapter.CollectionChanged += (sender, e) => { callCount++; Assert.AreEqual(adapter, sender); Assert.AreEqual(url, e.Item); Assert.AreEqual(0, e.Index); }; //action! remove the url from the dataitems list dataItems.Remove(dataItem); Assert.AreEqual(1, callCount); }
public void RemoveTest() { var a = new[] { new EClass(1), new EClass(2) }; var l = new EventedList <EClass>(a); l.Remove(a[0]); Assert.That(l.Count, Is.EqualTo(1)); }
public void CollectionChangedWhenValueIsRemoved() { var eventedList = new EventedList<int>(); var called = false; eventedList.Add(1); eventedList.CollectionChanged += delegate { called = true; }; eventedList.Remove(1); Assert.IsTrue(called); }
public void CollectionChangedWhenValueIsRemoved() { var eventedList = new EventedList <int>(); var called = false; eventedList.Add(1); eventedList.CollectionChanged += delegate { called = true; }; eventedList.Remove(1); Assert.IsTrue(called); }
public void TestRemove() { Init(); m_uut.AddRange(new string[] { "Bob", "Mary", "Sue" }); m_uut.Remove("Mary"); Assert.IsTrue(m_uut[0].Equals("Bob")); Assert.IsTrue(m_uut[1].Equals("Sue")); Assert.IsTrue(m_responses.Equals("m_uut_AboutToAddItems System.String[] | m_uut_AddedItems System.String[] | m_uut_ContentsChanged | m_uut_AboutToRemoveItem Mary | m_uut_RemovedItem Mary | m_uut_ContentsChanged | ")); Console.WriteLine(m_responses); }
public void UnsubscribeFromRemovedItems() { var eventedList = new EventedList <MockClassWithTwoProperties>(); var aPropertyChangeCount = 0; var listPropertyChangeCount = 0; var a = new MockClassWithTwoProperties { StringProperty = "a" }; eventedList.Add(a); eventedList.PropertyChanged += delegate { listPropertyChangeCount++; }; a.PropertyChanged += delegate { aPropertyChangeCount++; }; // replace item eventedList.Remove(a); a.StringProperty = "a2"; Assert.AreEqual(0, listPropertyChangeCount); Assert.AreEqual(1, aPropertyChangeCount); }
public void CollectionChangedRemoveDataItemsResultInCollectionChangedForAdapter() { //create a list of dataItem containing urls IEventedList<IDataItem> dataItems = new EventedList<IDataItem>(); var url = new Url(); var dataItem = new DataItem(url); dataItems.Add(dataItem); //adapter for the list var adapter = new DataItemListAdapter<Url>(dataItems); int callCount = 0; adapter.CollectionChanged += (sender, e) => { callCount++; Assert.AreEqual(adapter, sender); Assert.AreEqual(url, e.Item); Assert.AreEqual(0, e.Index); }; //action! remove the url from the dataitems list dataItems.Remove(dataItem); Assert.AreEqual(1, callCount); }
public void List_Remove() { var lst = new EventedList<string, string>("CONTEXT", false); var first = true; lst.GetReadOnlyEvent = (_) => false; lst.Add("a"); lst.Add("b"); lst.Add("c"); Assert.AreEqual(3, lst.Count); lst.ChangeEvent = (l, ct, p, idx, v) => { Assert.AreEqual( EventedList<string, string>.ChangeType.Remove, ct); Assert.AreEqual( first ? EventPhase.Before : EventPhase.After, p); Assert.AreEqual( -1, idx); Assert.AreEqual( "b", v); first = false; }; lst.Remove("b"); Assert.AreEqual(2, lst.Count); }
public void UnsubscribeFromRemovedItems() { var eventedList = new EventedList<MockClassWithTwoProperties>(); var aPropertyChangeCount = 0; var listPropertyChangeCount = 0; var a = new MockClassWithTwoProperties {StringProperty = "a"}; eventedList.Add(a); eventedList.PropertyChanged += delegate { listPropertyChangeCount++; }; a.PropertyChanged += delegate { aPropertyChangeCount++; }; // replace item eventedList.Remove(a); a.StringProperty = "a2"; Assert.AreEqual(0, listPropertyChangeCount); Assert.AreEqual(1, aPropertyChangeCount); }