public void TestSelect() { 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(thr, 3, 2, 1); ExpectList(one.Select(delegate(int i) { return(i + 1); }), 4); ExpectList(two.Select(delegate(int i) { return(i + 1); }), 4, 3); ExpectList(thr.Select(delegate(int i) { return(i + 1); }), 4, 3, 2); ExpectList(two.Select(delegate(int i) { return(i == 3 ? 3 : 0); }), 3, 0); ExpectList(thr.Select(delegate(int i) { return(i == 3 ? 3 : 0); }), 3, 0, 0); ExpectList(thr.Select(delegate(int i) { return(i == 1 ? 0 : i); }), 3, 2, 0); Assert.That(one.SmartSelect(delegate(int i) { return(i); }).ToVList() == one.ToVList()); Assert.That(two.SmartSelect(delegate(int i) { return(i); }).ToVList() == two.ToVList()); Assert.That(thr.SmartSelect(delegate(int i) { return(i); }).ToVList() == thr.ToVList()); ExpectList(one.SmartSelect(delegate(int i) { return(i + 1); }), 4); ExpectList(two.SmartSelect(delegate(int i) { return(i + 1); }), 4, 3); ExpectList(thr.SmartSelect(delegate(int i) { return(i + 1); }), 4, 3, 2); ExpectList(two.SmartSelect(delegate(int i) { return(i == 3 ? 3 : 0); }), 3, 0); ExpectList(thr.SmartSelect(delegate(int i) { return(i == 3 ? 3 : 0); }), 3, 0, 0); ExpectList(thr.SmartSelect(delegate(int i) { return(i == 1 ? 0 : i); }), 3, 2, 0); Assert.That(thr.SmartSelect(delegate(int i) { return(i == 1 ? 0 : i); }).WithoutLast(1) == thr.WithoutLast(1)); }