Exemple #1
0
        public void ReplaceExistingSublist_OldSublistEmpty_FiresAddCollectionChanged()
        {
            Person replacement = new Person("Ninja", 23);

            ClinqTestFactory.InitializeParents(replacement);
            _source[1].Parents = new ObservableCollection <Person>();

            int callCount = 0;

            _target.CollectionChanged += (sender, args) =>
            {
                callCount++;

                Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action);
                Assert.AreEqual(2, args.NewStartingIndex);
                CollectionAssert.AreEquivalent(replacement.Parents, args.NewItems);

                Assert.AreEqual(4, _target.Count);
                Assert.AreEqual("BobParent0", _target[0].Name);
                Assert.AreEqual("BobParent1", _target[1].Name);
                Assert.AreEqual("NinjaParent0", _target[2].Name);
                Assert.AreEqual("NinjaParent1", _target[3].Name);
            };

            _source[1] = replacement;

            Assert.AreEqual(1, callCount);
        }
Exemple #2
0
 public void Setup()
 {
     _source = ClinqTestFactory.CreateTwoPersonSource();
     _target = new SelectReadOnlyContinuousCollection <Person, string>(
         _source,
         p => p.Name);
 }
Exemple #3
0
 public void Setup()
 {
     _source = ClinqTestFactory.CreateTwoPersonSource();
     _target = new FilteringReadOnlyContinuousCollection <Person>(
         _source,
         p => p.Age > 10);
 }
Exemple #4
0
        public void AddNewSublistToSource_Always_FireCollectionChangedEvent()
        {
            Person newPerson = new Person("Ninja", 23);

            ClinqTestFactory.InitializeParents(newPerson);

            int callCount = 0;

            _target.CollectionChanged += (sender, args) =>
            {
                callCount++;
                Assert.AreEqual(NotifyCollectionChangedAction.Add, args.Action);
                Assert.AreEqual(2, args.NewStartingIndex);
                CollectionAssert.AreEquivalent(newPerson.Parents, args.NewItems);
            };

            _source.Insert(1, newPerson);
            Assert.AreEqual(1, callCount);

            Assert.AreEqual(6, _target.Count);
            Assert.AreEqual("BobParent0", _target[0].Name);
            Assert.AreEqual("BobParent1", _target[1].Name);
            Assert.AreEqual("NinjaParent0", _target[2].Name);
            Assert.AreEqual("NinjaParent1", _target[3].Name);
            Assert.AreEqual("JimParent0", _target[4].Name);
            Assert.AreEqual("JimParent1", _target[5].Name);
        }
Exemple #5
0
 public void SetUp()
 {
     _source         = ClinqTestFactory.CreateSixPersonSource();
     _source[1].Age  = 20; // same as _source[2].age
     _source[2].Age  = 20;
     _source[1].Name = "Zoolander";
     _source[2].Name = "Alfonse";
 }
 public void Setup()
 {
     _source = ClinqTestFactory.CreateSixPersonSourceWithDuplicates();
     _first  = _source[0];
     _second = _source[3];
     _third  = _source[4];
     _target = new ListIndexer <Person>(_source);
 }
        public void Construct_FirstListIsEmpty_OutputIsSecondList()
        {
            _first  = new ObservableCollection <Person>();
            _second = ClinqTestFactory.CreateTwoPersonSource();

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

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

            var expectedConcatenation = ConcatenateFirstAndSecond();

            CollectionAssert.AreEquivalent(expectedConcatenation, _target);
        }
Exemple #9
0
        public void ChangingItem_LastItemInGroup_GroupRemoved()
        {
            _source = ClinqTestFactory.CreateTwoPersonSource();

            var group = from p in _source group p by p.Name;

            _source[0].Name = "Foo";

            Assert.AreEqual(2, group.Count);
        }
        public void Setup()
        {
            _first  = ClinqTestFactory.CreateTwoPersonSource();
            _second = new ObservableCollection <Person>();

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

            _person1 = _first[0];
            _person2 = _first[1];
        }
Exemple #11
0
        public void Setup()
        {
            _source = ClinqTestFactory.CreateTwoPersonSourceWithParents();

            _parents = new ObservableCollection <ObservableCollection <Person> >()
            {
                _source[0].Parents,
                _source[1].Parents
            };

            _target = _source.SelectMany(src => src.Parents);
        }
Exemple #12
0
        public void GroupBy_MultipleGroups_UsesAnonymouseTypeForComparison()
        {
            _source = ClinqTestFactory.CreateTwoPersonSource();

            var group = from p in _source group p by new { p.Name, p.Age };

            _source.Add(new Person("Bob", 10));
            _source.Add(new Person("Jim", 20));

            Assert.AreEqual(2, group.Count);
            Assert.AreEqual(2, group[group.Count - 1].Count);
        }
Exemple #13
0
        public void AddItemToSource_ItemIsADuplicate_AddedToCorrectGroup()
        {
            _source = ClinqTestFactory.CreateTwoPersonSource();

            var group = from p in _source group p
                        by new { p.Name, p.Age };

            _source.Add(_source[0]);

            Assert.AreEqual(2, group.Count);
            Assert.AreEqual(2, group[0].Count);
        }
Exemple #14
0
        public void Setup()
        {
            _outer = ClinqTestFactory.CreateTwoPersonSource();
            _inner = ClinqTestFactory.CreateTwoPersonSource();

            _target = from outerPerson in _outer
                      join innerPerson in _inner on outerPerson.Age equals innerPerson.Age into innersMatchingOuterAge
                      select new Pair <Person, ReadOnlyContinuousCollection <Person> >(outerPerson, innersMatchingOuterAge);

            _standardLinqResults = from outerPerson in _outer.AsEnumerable()
                                   join innerPerson in _inner on outerPerson.Age equals innerPerson.Age into innersMatchingOuterAge
                                   select new Pair <Person, IEnumerable <Person> >(outerPerson, innersMatchingOuterAge);
        }
        public void Setup()
        {
            _source = ClinqTestFactory.CreateTwoPersonSource();

            _propertyAccessTree = new PropertyAccessTree();
            ParameterNode parameterNode = new ParameterNode(typeof(Person), "person");

            _propertyAccessTree.Children.Add(parameterNode);

            var agePropertyAccessNode = new PropertyAccessNode(typeof(Person).GetProperty("Age"));

            parameterNode.Children.Add(agePropertyAccessNode);

            _target = new NotifyCollectionChangedMonitor <Person>(_propertyAccessTree, _source);
        }
        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 ResetFirst_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);

            first.FireReset();

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

            CollectionAssert.AreEquivalent(expectedConcatenation, _target);
        }
Exemple #18
0
        public void ReplaceItemInSource_Always_FireCollectionChangedEvent()
        {
            Person replacement = new Person("Ninja", 23);

            ClinqTestFactory.InitializeParents(replacement);

            int callCount = 0;

            _target.CollectionChanged += (sender, args) =>
            {
                callCount++;
                TestUtilities.AssertReplace(args, 2, replacement.Parents.ToArray(), _parents[1].ToArray());
            };

            _source[1] = replacement;

            Assert.AreEqual(1, callCount);
        }
        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);
        }
Exemple #20
0
        public void ReplaceItemInSource_Always_FireCollectionChangedEvent()
        {
            Person replacement = new Person("Ninja", 23);

            ClinqTestFactory.InitializeParents(replacement);

            int callCount = 0;

            _target.CollectionChanged += (sender, args) =>
            {
                Assert.AreEqual(NotifyCollectionChangedAction.Replace, args.Action);

                Assert.AreEqual(2 + callCount, args.NewStartingIndex);
                Assert.AreEqual(replacement.Parents[callCount], args.NewItems[0]);
                Assert.AreEqual(_parents[1][callCount], args.OldItems[0]);

                callCount++;
            };

            _source[1] = replacement;

            Assert.AreEqual(2, callCount);
        }
 public void Setup()
 {
     _source = ClinqTestFactory.CreateSixPersonSourceWithDuplicates();
 }
Exemple #22
0
 public void Setup()
 {
     _source = ClinqTestFactory.CreateSixPersonSourceWithDuplicates();
     _target = new DistinctReadOnlyContinuousCollection <Person>(_source);
 }
Exemple #23
0
 public void Setup()
 {
     _source = ClinqTestFactory.CreateTwoPersonSource();
 }
 protected void SetUp10PersonSource()
 {
     _source = new ContinuousCollection <Person>(ClinqTestFactory.CreateAnyPersonSource(10).ToList());
     setupTargetAndHandlers();
 }
 public void Setup()
 {
     _source = ClinqTestFactory.CreateTwoPersonSource();
     _target = new PassThroughReadOnlyContinuousCollection <Person>(_source);
 }
        public void Setup()
        {
            _source = ClinqTestFactory.CreateTwoPersonSource();

            _target = new CollectionMonitor <Person>(_source);
        }
 public void SetUp()
 {
     _source = ClinqTestFactory.CreateSixPersonSource();
 }
Exemple #28
0
 public void Setup()
 {
     _source = ClinqTestFactory.CreateGroupablePersonSource();
 }