public void Construct_BothListsAreEmpty_OutputIsEmpty()
        {
            _first  = new ObservableCollection <Person>();
            _second = new ObservableCollection <Person>();
            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, _second);

            Assert.AreEqual(0, _target.Count);
        }
        public void Construct_BothListsHaveValues_OutputHasItemsFromBothLists()
        {
            _second = ClinqTestFactory.CreateTwoPersonSource();
            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, _second);

            var expectedConcatenation = ConcatenateFirstAndSecond();

            CollectionAssert.AreEquivalent(expectedConcatenation, _target);
        }
        public void Construct_FirstListIsEmpty_OutputIsSecondList()
        {
            _first  = new ObservableCollection <Person>();
            _second = ClinqTestFactory.CreateTwoPersonSource();

            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, _second);

            CollectionAssert.AreEquivalent(_second, _target);
        }
        public void Setup()
        {
            _first  = ClinqTestFactory.CreateTwoPersonSource();
            _second = new ObservableCollection <Person>();

            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, _second);

            _person1 = _first[0];
            _person2 = _first[1];
        }
        public void RemoveRangeFromSecond_Always_RaisesNotifyCollectionChangedWithRemoveActionAndCorrectValuesForEachItemRemoved()
        {
            var continuousSecondCollection = new ContinuousCollection <Person>(_first.ToList());

            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection);

            var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target);

            continuousSecondCollection.RemoveRange(0, 2);

            Assert.AreEqual(1, eventArgsList.Count);

            TestUtilities.AssertRemove(eventArgsList[0], 2, _person1, _person2);
        }
        public void ReplaceRangeOnSecond_Always_RaisesNotifyCollectionChangedWithReplaceAction()
        {
            var continuousSecondCollection = new ContinuousCollection <Person>(_first.ToList());

            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection);

            var people = new List <Person> {
                new Person(), new Person()
            };

            var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target);

            continuousSecondCollection.ReplaceRange(0, people);

            Assert.AreEqual(1, eventArgsList.Count);

            TestUtilities.AssertReplace(eventArgsList[0], 2, people.ToArray(), new[] { _person1, _person2 });
        }
        public void AddRangeToSecond_Always_RaisesNotifyCollectionChangedWithAddActionAndCorrectValues()
        {
            var continuousSecondCollection = new ContinuousCollection <Person>();

            _target = new ConcatReadOnlyContinuousCollection <Person>(_first, continuousSecondCollection);

            var people = new List <Person> {
                new Person(), new Person()
            };

            var eventArgsList = TestUtilities.GetCollectionChangedEventArgsList(_target);

            continuousSecondCollection.AddRange(people);

            Assert.AreEqual(1, eventArgsList.Count);

            TestUtilities.AssertAdd(eventArgsList[0], 2, people.ToArray());
        }
        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 ConcatReadOnlyContinuousCollection <Person>(first, second);

            second.FireReset();

            Assert.AreEqual(7, _target.Count);
            var expectedConcatenation = Concatenate(first, second);

            CollectionAssert.AreEquivalent(expectedConcatenation, _target);
        }
        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 ConcatReadOnlyContinuousCollection <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);
        }