public void It_throws_exception_when_new_index_is_greater_than_count() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); Assert.Throws <ArgumentOutOfRangeException>(() => { collection.Move(0, 4); }); }
public void It_throws_exception_when_old_index_is_less_than_zero() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); Assert.Throws <ArgumentOutOfRangeException>(() => { collection.Move(-1, 2); }); }
public void It_moves_the_item_when_new_index_and_old_index_are_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); Assert.DoesNotThrow(() => { collection.Move(0, 2); }); Assert.That(collection.Count, Is.EqualTo(3)); Assert.That(collection[0], Is.EqualTo("2")); Assert.That(collection[1], Is.EqualTo("3")); Assert.That(collection[2], Is.EqualTo("1")); }
public void It_invokes_PropertyChanged_when_new_index_and_old_index_are_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); var propertyChangedEventArgs = new List <PropertyChangedEventArgs>(); ((INotifyPropertyChanged)collection).PropertyChanged += (sender, args) => { propertyChangedEventArgs.Add(args); }; collection.Move(0, 2); Assert.That(propertyChangedEventArgs.Count, Is.EqualTo(1)); Assert.That(propertyChangedEventArgs.Any(p => p.PropertyName.Equals("Item[]")), Is.True); }
public void It_invokes_CollectionChanged_when_new_index_and_old_index_are_in_range() { var collection = new SynchronizedObservableCollection <string>(new List <string> { "1", "2", "3" }); NotifyCollectionChangedEventArgs collectionChangedEventArgs = null; collection.CollectionChanged += (sender, args) => { collectionChangedEventArgs = args; }; collection.Move(0, 2); Assert.That(collectionChangedEventArgs.Action, Is.EqualTo(NotifyCollectionChangedAction.Move)); Assert.That(collectionChangedEventArgs.OldItems[0], Is.EqualTo("1")); Assert.That(collectionChangedEventArgs.OldStartingIndex, Is.EqualTo(0)); Assert.That(collectionChangedEventArgs.NewItems[0], Is.EqualTo("1")); Assert.That(collectionChangedEventArgs.NewStartingIndex, Is.EqualTo(2)); }