Exemple #1
0
        public void TestWhere()
        {
            WList <int> one = new WList <int>(); one.Add(3);
            WList <int> two = one.Clone();       two.Add(2);
            WList <int> thr = two.Clone();       thr.Add(1);

            ExpectList(one.Where(delegate(int i) { return(false); }));
            ExpectList(two.Where(delegate(int i) { return(false); }));
            ExpectList(thr.Where(delegate(int i) { return(false); }));
            Assert.That(one.Where(delegate(int i) { return(true); }).ToVList() == one.ToVList());
            Assert.That(two.Where(delegate(int i) { return(true); }).ToVList() == two.ToVList());
            Assert.That(thr.Where(delegate(int i) { return(true); }).ToVList() == thr.ToVList());
            Assert.That(two.Where(delegate(int i) { return(i == 3); }).ToVList() == two.WithoutLast(1));
            Assert.That(thr.Where(delegate(int i) { return(i == 3); }).ToVList() == thr.WithoutLast(2));
            Assert.That(thr.Where(delegate(int i) { return(i > 1); }).ToVList() == thr.WithoutLast(1));
            ExpectList(two.Where(delegate(int i) { return(i == 2); }), 2);
            ExpectList(thr.Where(delegate(int i) { return(i == 2); }), 2);
        }