public void ReplaceRangeOnSecond_FirstContainsNewItems_RaisesNotifyCollectionChangedWithOneAddAndRemoveActionsForEachItemReplacedRemoved2() { var people = new List <Person> { new Person(), new Person() }; _first = new ObservableCollection <Person> { _person1, _person2, people[0], people[1] }; var continuousSecondCollection = new ContinuousCollection <Person> { _person1, _person2 }; _target = new ExceptReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.ReplaceRange(0, people); Assert.AreEqual(3, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 2, _person1, _person2); TestUtilities.AssertRemove(eventArgsList[1], 0, people[0]); TestUtilities.AssertRemove(eventArgsList[2], 0, people[1]); }
public void Setup() { _first = ClinqTestFactory.CreateTwoPersonSource(); _second = new ObservableCollection <Person>(); _target = new ExceptReadOnlyContinuousCollection <Person>(_first, _second); _person1 = _first[0]; _person2 = _first[1]; }
public void Construct_BothListHaveSameElements_OutputIsEmpty() { _second = new ObservableCollection <Person>(); for (int i = 0; i < _first.Count; i++) { _second.Add(_first[i]); } _target = new ExceptReadOnlyContinuousCollection <Person>(_first, _second); Assert.AreEqual(0, _target.Count); }
public void RemoveRangeFromFirst_Always_RaisesNotifyCollectionChangedWithAddActionAndCorrectValues2() { var continuousSecondCollection = new ContinuousCollection <Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.RemoveRange(0, 2); Assert.AreEqual(1, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 0, _first.ToArray()); }
public void AddRangeToSecond_Always_RaisesNotifyCollectionChangedWithRemoveActionAndCorrectValuesForEachItemRemoved() { var continuousSecondCollection = new ContinuousCollection <Person>(); _target = new ExceptReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.AddRange(_first); Assert.AreEqual(2, eventArgsList.Count); TestUtilities.AssertRemove(eventArgsList[0], 0, _person1); TestUtilities.AssertRemove(eventArgsList[1], 0, _person2); }
public void ResetSecond_Always_LeavesOutputIntact() { var people = ClinqTestFactory.CreateSixPersonSource(); var first = new TestContinuousCollection <Person>(people.ToList()); var second = new TestContinuousCollection <Person> { people[0] }; _target = new ExceptReadOnlyContinuousCollection <Person>(first, second); second.FireReset(); Assert.AreEqual(5, _target.Count); CollectionAssert.AreEquivalent(people.Skip(1), _target.Output); }
public void AddRangeToFirst_Always_RaisesNotifyCollectionChangedWithAddActionAndCorrectValues() { var continuousFirstCollection = new ContinuousCollection <Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection <Person>(continuousFirstCollection, _second); var people = new List <Person> { new Person(), new Person() }; var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousFirstCollection.AddRange(people); Assert.AreEqual(1, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 2, people.ToArray()); }
public void ResetOnSecond_Always_RaisesNotifyCollectionChangedWithResetAction() { var people = ClinqTestFactory.CreateSixPersonSource(); var first = new TestContinuousCollection <Person>(people.ToList()); var second = new TestContinuousCollection <Person> { people[0] }; _target = new ExceptReadOnlyContinuousCollection <Person>(first, second); var eventArgsList = new List <NotifyCollectionChangedEventArgs>(); _target.CollectionChanged += (sender, e) => eventArgsList.Add(e); second.FireReset(); Assert.AreEqual(1, eventArgsList.Count); Assert.AreEqual(NotifyCollectionChangedAction.Reset, eventArgsList[0].Action); }
public void ReplaceRangeOnFirst_Always_RaisesNotifyCollectionChangedWithRemoveActionsForEachItemReplacedAndOneAdd() { var continuousFirstCollection = new ContinuousCollection <Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection <Person>(continuousFirstCollection, _second); var people = new List <Person> { new Person(), new Person() }; var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousFirstCollection.ReplaceRange(0, people); Assert.AreEqual(3, eventArgsList.Count); TestUtilities.AssertRemove(eventArgsList[0], 0, _person1); TestUtilities.AssertRemove(eventArgsList[1], 0, _person2); TestUtilities.AssertAdd(eventArgsList[2], 0, people.ToArray()); }
public void Construct_BothListHaveSameElements_OutputIsEmpty() { _second = new ObservableCollection<Person>(); for (int i = 0; i < _first.Count; i++) { _second.Add(_first[i]); } _target = new ExceptReadOnlyContinuousCollection<Person>(_first, _second); Assert.AreEqual(0, _target.Count); }
public void ResetOnSecond_Always_RaisesNotifyCollectionChangedWithResetAction() { var people = ClinqTestFactory.CreateSixPersonSource(); var first = new TestContinuousCollection<Person>(people.ToList()); var second = new TestContinuousCollection<Person> { people[0] }; _target = new ExceptReadOnlyContinuousCollection<Person>(first, second); var eventArgsList = new List<NotifyCollectionChangedEventArgs>(); _target.CollectionChanged += (sender, e) => eventArgsList.Add(e); second.FireReset(); Assert.AreEqual(1, eventArgsList.Count); Assert.AreEqual(NotifyCollectionChangedAction.Reset, eventArgsList[0].Action); }
public void RemoveRangeFromFirst_Always_RaisesNotifyCollectionChangedWithAddActionAndCorrectValues2() { var continuousSecondCollection = new ContinuousCollection<Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection<Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.RemoveRange(0, 2); Assert.AreEqual(1, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 0, _first.ToArray()); }
public void ReplaceRangeOnSecond_FirstContainsNewItems_RaisesNotifyCollectionChangedWithOneAddAndRemoveActionsForEachItemReplacedRemoved2() { var people = new List<Person> { new Person(), new Person() }; _first = new ObservableCollection<Person> { _person1, _person2, people[0], people[1] }; var continuousSecondCollection = new ContinuousCollection<Person> { _person1, _person2 }; _target = new ExceptReadOnlyContinuousCollection<Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.ReplaceRange(0, people); Assert.AreEqual(3, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 2, _person1, _person2); TestUtilities.AssertRemove(eventArgsList[1], 0, people[0]); TestUtilities.AssertRemove(eventArgsList[2], 0, people[1]); }
public void AddRangeToSecond_Always_RaisesNotifyCollectionChangedWithRemoveActionAndCorrectValuesForEachItemRemoved() { var continuousSecondCollection = new ContinuousCollection<Person>(); _target = new ExceptReadOnlyContinuousCollection<Person>(_first, continuousSecondCollection); var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousSecondCollection.AddRange(_first); Assert.AreEqual(2, eventArgsList.Count); TestUtilities.AssertRemove(eventArgsList[0], 0, _person1); TestUtilities.AssertRemove(eventArgsList[1], 0, _person2); }
public void ReplaceRangeOnFirst_Always_RaisesNotifyCollectionChangedWithRemoveActionsForEachItemReplacedAndOneAdd() { var continuousFirstCollection = new ContinuousCollection<Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection<Person>(continuousFirstCollection, _second); var people = new List<Person> { new Person(), new Person() }; var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousFirstCollection.ReplaceRange(0, people); Assert.AreEqual(3, eventArgsList.Count); TestUtilities.AssertRemove(eventArgsList[0], 0, _person1); TestUtilities.AssertRemove(eventArgsList[1], 0, _person2); TestUtilities.AssertAdd(eventArgsList[2], 0, people.ToArray()); }
public void AddRangeToFirst_Always_RaisesNotifyCollectionChangedWithAddActionAndCorrectValues() { var continuousFirstCollection = new ContinuousCollection<Person>(_first.ToList()); _target = new ExceptReadOnlyContinuousCollection<Person>(continuousFirstCollection, _second); var people = new List<Person> { new Person(), new Person() }; var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target); continuousFirstCollection.AddRange(people); Assert.AreEqual(1, eventArgsList.Count); TestUtilities.AssertAdd(eventArgsList[0], 2, people.ToArray()); }
public void Setup() { _first = ClinqTestFactory.CreateTwoPersonSource(); _second = new ObservableCollection<Person>(); _target = new ExceptReadOnlyContinuousCollection<Person>(_first, _second); _person1 = _first[0]; _person2 = _first[1]; }
public void ResetSecond_Always_LeavesOutputIntact() { var people = ClinqTestFactory.CreateSixPersonSource(); var first = new TestContinuousCollection<Person>(people.ToList()); var second = new TestContinuousCollection<Person> { people[0] }; _target = new ExceptReadOnlyContinuousCollection<Person>(first, second); second.FireReset(); Assert.AreEqual(5, _target.Count); CollectionAssert.AreEquivalent(people.Skip(1), _target.Output); }