public void Add() { var xs = Enumerable.Range(0, 10000).ToList(); var actual = new FilteredView <int>(xs, Predicate); Assert.Throws <InvalidOperationException>(() => actual.Add(1)); bool Predicate(int x) { return(x % 2 == 0); } }
public void Count2() { var xs = Enumerable.Range(0, 10000).ToList(); var expected = xs.Where(Predicate).Count(); var actual = new FilteredView <int>(xs, Predicate).Count; Assert.Equal(expected, actual); bool Predicate(int x) { return(x % 17 < 7); } }
public void Indexing2() { var xs = Enumerable.Range(0, 10000).ToList(); var expected = xs.Where(Predicate).ToList(); var actual = new FilteredView <int>(xs, Predicate); Assert.Equal(Copy(actual), expected); bool Predicate(int x) { return(x % 2 == 0); } }
public void IndexOf() { var ints = Enumerable.Range(0, 10000).ToList(); var xs = ints.Where(Predicate).ToList(); var ys = new FilteredView <int>(ints, Predicate); for (int i = 0; i != 10000; ++i) { var expected = xs.IndexOf(i); var actual = ys.IndexOf(i); Assert.Equal(expected, actual); } bool Predicate(int x) { return(x % 2 == 0); } }