public void OnMasterCollectionChanged_Should_Maintain_State_After_Master_Remove_With_Index(int index) { // Arrange List <Int32> master = new List <Int32>() { 1, 2, 3 }; ISlaveObservableCollection <Int32> slave = CreateInstance(() => master); NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, master[index], index); // Act master.RemoveAt(index); slave.OnMasterCollectionChanged(args); // Assert Assert.Equal(master, slave); }
public void OnMasterCollectionChanged_Should_Maintain_State_After_Master_Move(int oldIndex, int newIndex) { // Arrange ObservableCollection <Int32> master = new ObservableCollection <Int32>() { 1, 2, 3 }; ISlaveObservableCollection <Int32> slave = CreateInstance(() => master); NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, master[oldIndex], newIndex, oldIndex); // Act master.Move(oldIndex, newIndex); slave.OnMasterCollectionChanged(args); // Assert Assert.Equal(master, slave); }
public void OnMasterCollectionChanged_Should_Maintain_State_After_Master_Add_Without_Index() { // Arrange List <Int32> master = new List <Int32> { 1, 2 }; ISlaveObservableCollection <Int32> slave = CreateInstance(() => master); int newItem = 7; NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, newItem); // Act master.Add(newItem); slave.OnMasterCollectionChanged(args); // Assert Assert.Equal(master, slave); }
public void OnMasterCollectionChanged_Should_Maintain_State_After_Master_Reset() { // Arrange List <Int32> master = new List <Int32>() { 1, 2, 3 }; ISlaveObservableCollection <Int32> slave = CreateInstance(() => master); NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset); // Act master.Add(7); master[0] = 5; slave.OnMasterCollectionChanged(args); // Assert Assert.Equal(master, slave); }
public void OnMasterCollectionChanged_Should_Maintain_State_After_Master_Replace_Without_Index(int value) { // Arrange List <Int32> master = new List <Int32>() { 1, 2, 3 }; Int32 newValue = 7; ISlaveObservableCollection <Int32> slave = CreateInstance(() => master); NotifyCollectionChangedEventArgs args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, newValue, (object)value); // Act master[master.IndexOf(value)] = newValue; slave.OnMasterCollectionChanged(args); // Assert Assert.Equal(master, slave); }