예제 #1
0
파일: RWList.cs 프로젝트: lydonchandra/Loyc
        public void TestWhere()
        {
            RWList <int> one = new RWList <int>(); one.Add(3);
            RWList <int> two = one.Clone();       two.Add(2);
            RWList <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); }).ToRVList() == one.ToRVList());
            Assert.That(two.Where(delegate(int i) { return(true); }).ToRVList() == two.ToRVList());
            Assert.That(thr.Where(delegate(int i) { return(true); }).ToRVList() == thr.ToRVList());
            Assert.That(two.Where(delegate(int i) { return(i == 3); }).ToRVList() == two.WithoutLast(1));
            Assert.That(thr.Where(delegate(int i) { return(i == 3); }).ToRVList() == thr.WithoutLast(2));
            Assert.That(thr.Where(delegate(int i) { return(i > 1); }).ToRVList() == thr.WithoutLast(1));
            ExpectList(two.Where(delegate(int i) { return(i == 2); }), 2);
            ExpectList(thr.Where(delegate(int i) { return(i == 2); }), 2);
        }