Example #1
0
        public void Transformations_Relational_Select1()
        {
            bool nextItemCalled = false;
            int  expectedResult = 1;

            var select = source.Select(s => s.Length);

            select.CollectionChanged += (o, e) =>
            {
                Assert.AreEqual(NotifyCollectionChangedAction.Add, e.Action);
                Assert.AreEqual(expectedResult, e.NewItems[0]);
                nextItemCalled = true;
            };

            select.AssertEmpty();

            source.Add("a");

            Assert.IsTrue(nextItemCalled);
            select.AssertContainsOnly(1);

            nextItemCalled = false;
            expectedResult = 2;

            source.Add("aa");
            Assert.IsTrue(nextItemCalled);
            select.AssertContainsOnly(1, 2);

            nextItemCalled = false;
            expectedResult = 0;

            select.Successors.UnsetAll();

            source.Add("");

            Assert.IsFalse(nextItemCalled);
        }