public void OldListToOldList_WithGC() { var list = new MyTestCollection(); list.Add(0); list.Add(1); var target = new ArrayList(); var binding = CollectionBindingHelper.Bind((int i) => i, target, i => i, list); Assert.AreEqual(1, target[1]); GC.KeepAlive(binding); GC.KeepAlive(list); GC.KeepAlive(target); }
public void TaskbarButtonInfoCollectionBehavior() { ObservableCollection <int> collection1 = new ObservableCollection <int>(); MyTestCollection <string> collection2 = new MyTestCollection <string>(); collection2.Add("434"); IDisposable stopBinding = CollectionBindingHelper.Bind(collection1, s => int.Parse(s), collection2, a => a.ToString()); collection2.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, collection2[0], 0)); AssertHelper.AssertEnumerablesAreEqual(new int[] { 434 }, collection1); collection1.Add(100); stopBinding.Dispose(); collection2.Remove("100"); CreateAndCheckBinding(() => CollectionBindingHelper.Bind(collection1, s => int.Parse(s), collection2, a => a.ToString())); collection2.OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, "100", 0)); AssertHelper.AssertEnumerablesAreEqual(new int[] { 434 }, collection1); }