public ObservableCollectionSynchronizerTests() { collection1 = new ObservableCollection <int>(new[] { 1, 2, 3 }); collection2 = new ObservableCollection <string>(); _synchronizer = new ObservableCollectionSynchronizer <int, string>(collection1, collection2, (x) => x.ToString()); }
public void Setup() { _destination = new ObservableCollection <string>(); _sync = new ObservableCollectionSynchronizer <string>(_destination); _source1 = new ObservableCollection <int>(); _source2 = new ObservableCollection <string>(); _source1Selector = (i => i.ToString()); }
public BindableGrid() { ColumnSyncronizer = new ObservableCollectionSynchronizer <ColumnDefinition> { Destination = ColumnDefinitions }; RowSyncronizer = new ObservableCollectionSynchronizer <RowDefinition> { Destination = RowDefinitions }; }
public void Should_Be_Disposable() { var reference = new WeakReference(_synchronizer); Assert.True(reference.IsAlive); _synchronizer.Dispose(); _synchronizer = null; GC.Collect(); Assert.False(reference.IsAlive); }
public void ElementInitiallyAdded_CollectionContainsElement() { var integerList = new ObservableCollection <int> { 1, 3 }; var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); Assert.Equal(2, stringList.Count); Assert.Equal("1", stringList.First()); Assert.Equal("3", stringList.Last()); }
public void ElementInserted_CollectionContainsElement() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(3); integerList.Insert(1, 2); Assert.Equal(3, stringList.Count); Assert.Equal("1", stringList[0]); Assert.Equal("2", stringList[1]); Assert.Equal("3", stringList[2]); }
public void ElementsCleared_CollectionIsEmpty() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(2); integerList.Add(3); integerList.Add(4); integerList.Clear(); Assert.Empty(stringList); }
public void ElementRemovedAt_CollectionNotContainsElement() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(2); integerList.Add(3); integerList.Add(4); integerList.RemoveAt(2); Assert.Equal(3, stringList.Count); Assert.Equal("1", stringList[0]); Assert.Equal("2", stringList[1]); Assert.Equal("4", stringList[2]); }
public void Dispose_CollectionDoesntUpdateAnymore() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var synchronizer = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(3); synchronizer.Dispose(); integerList.Add(6); integerList.Add(7); Assert.Equal(2, stringList.Count); Assert.Equal("1", stringList.First()); Assert.Equal("3", stringList.Last()); }
/// <summary> /// Main entry point of the application. /// </summary> /// <param name="pArguments">The arguments.</param> static void Main(string[] pArguments) { ObservableCollection <int> lSourceCollection = new ObservableCollection <int>(); ObservableCollection <string> lTargetCollection = new ObservableCollection <string>(); ObservableCollectionSynchronizer <int, string> lSynchronizer = new ObservableCollectionSynchronizer <int, string>(lSourceCollection, lTargetCollection); Console.WriteLine("Add a single value in source"); lSourceCollection.Add(12); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); Console.WriteLine("Add multiple values in source"); lSourceCollection.Add(17); lSourceCollection.Add(18); lSourceCollection.Add(12); lSourceCollection.Add(14); lSourceCollection.Add(14); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); Console.WriteLine("Remove a value duplicated in target"); lTargetCollection.Remove("12"); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); Console.WriteLine("Insert a single value in target"); lTargetCollection.Insert(1, "34"); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); Console.WriteLine("Remove a value duplicated in source"); lSourceCollection.Remove(12); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); Console.WriteLine("Clear source"); lSourceCollection.Clear(); Console.WriteLine(lSynchronizer.ToString()); Debug.Assert(lTargetCollection.Count == lSourceCollection.Count); }
public void ElementMoved_CollectionContainsElementAtRightPosition() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(2); integerList.Add(3); integerList.Add(4); integerList.Move(1, 3); Assert.Equal(4, stringList.Count); Assert.Equal("1", stringList[0]); Assert.Equal("3", stringList[1]); Assert.Equal("4", stringList[2]); Assert.Equal("2", stringList[3]); }
public void ElementReplaced_CollectionContainsNewElement() { var integerList = new ObservableCollection <int>(); var stringList = new ObservableCollection <string>(); var _ = new ObservableCollectionSynchronizer <int, string>(integerList, stringList, x => x.ToString(), x => x.ToString()); integerList.Add(1); integerList.Add(2); integerList.Add(3); integerList.Add(4); integerList[2] = 5; Assert.Equal(4, stringList.Count); Assert.Equal("1", stringList[0]); Assert.Equal("2", stringList[1]); Assert.Equal("5", stringList[2]); Assert.Equal("4", stringList[3]); }
public void Setup() { _destination = new ObservableCollection <string>(); _sync = new ObservableCollectionSynchronizer <string>(_destination); _source = new ObservableCollection <string>(); }
public BindableGrid() { ColumnSyncronizer = new ObservableCollectionSynchronizer<ColumnDefinition> {Destination = ColumnDefinitions}; RowSyncronizer = new ObservableCollectionSynchronizer<RowDefinition> {Destination = RowDefinitions}; }
public void Stop() { this._Selector.SelectionChanged -= selector_SelectionChanged; this._Connector.Stop(); this._Connector = null; }
public void Start() { this._Selector.SelectionChanged += selector_SelectionChanged; if(this._Connector != null) { throw new InvalidOperationException(); } this._Connector = this._Collection.NotifyToCollectionWeak(GetSelectedItemsList(this._Selector)); }