Beispiel #1
0
        public void TestSelect()
        {
            FVList <int> one = new FVList <int>(3);
            FVList <int> two = one.Clone().Add(2);
            FVList <int> thr = two.Clone().Add(1);

            ExpectList(thr, 1, 2, 3);

            ExpectList(one.Select(delegate(int i) { return(i + 1); }), 4);
            ExpectList(two.Select(delegate(int i) { return(i + 1); }), 3, 4);
            ExpectList(thr.Select(delegate(int i) { return(i + 1); }), 2, 3, 4);
            ExpectList(two.Select(delegate(int i) { return(i == 3 ? 3 : 0); }), 0, 3);
            ExpectList(thr.Select(delegate(int i) { return(i == 3 ? 3 : 0); }), 0, 0, 3);
            ExpectList(thr.Select(delegate(int i) { return(i == 1 ? 0 : i); }), 0, 2, 3);

            Assert.That(one.SmartSelect(delegate(int i) { return(i); }) == one);
            Assert.That(two.SmartSelect(delegate(int i) { return(i); }) == two);
            Assert.That(thr.SmartSelect(delegate(int i) { return(i); }) == thr);
            ExpectList(one.SmartSelect(delegate(int i) { return(i + 1); }), 4);
            ExpectList(two.SmartSelect(delegate(int i) { return(i + 1); }), 3, 4);
            ExpectList(thr.SmartSelect(delegate(int i) { return(i + 1); }), 2, 3, 4);
            ExpectList(two.SmartSelect(delegate(int i) { return(i == 3 ? 3 : 0); }), 0, 3);
            ExpectList(thr.SmartSelect(delegate(int i) { return(i == 3 ? 3 : 0); }), 0, 0, 3);
            ExpectList(thr.SmartSelect(delegate(int i) { return(i == 1 ? 0 : i); }), 0, 2, 3);
            Assert.That(thr.SmartSelect(delegate(int i) { return(i == 1 ? 0 : i); }).WithoutFirst(1) == two);
        }
Beispiel #2
0
        public void TestWhere()
        {
            FVList <int> one = new FVList <int>(3);
            FVList <int> two = one.Clone().Add(2);
            FVList <int> thr = two.Clone().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); }) == one);
            Assert.That(two.Where(delegate(int i) { return(true); }) == two);
            Assert.That(thr.Where(delegate(int i) { return(true); }) == thr);
            Assert.That(two.Where(delegate(int i) { return(i == 3); }) == one);
            Assert.That(thr.Where(delegate(int i) { return(i == 3); }) == one);
            Assert.That(thr.Where(delegate(int i) { return(i > 1); }) == two);
            ExpectList(two.Where(delegate(int i) { return(i == 2); }), 2);
            ExpectList(thr.Where(delegate(int i) { return(i == 2); }), 2);
        }