public void HasSeveralItemsArrayPredicate() { var x = Enumerable.Range(1, 1024).ToArray(); var y = Enumerable.Range(1, 1024).Select(a => new Tuple<int, int>(a,a)).ToArray(); var z = Enumerable.Range(1, 1024).Select(a => new { A = a}).ToArray(); var dict = new SortedDictionary<int, int>(x.ToDictionary(a => a, a => a)); Assert.IsTrue(x.HasSeveralItems(10, val => val%3 == 0)); Assert.IsTrue(x.HasSeveralItems(300, val => val%3 == 0)); Assert.IsFalse(x.HasSeveralItems(1025, val => val%3 == 0)); Assert.IsTrue(y.HasSeveralItems(10, val => val.Item1%3 == 0)); Assert.IsTrue(y.HasSeveralItems(300, val => val.Item1%3 == 0)); Assert.IsFalse(y.HasSeveralItems(1025, val => val.Item1%3 == 0)); Assert.IsTrue(z.HasSeveralItems(10, val => val.A%3 == 0)); Assert.IsTrue(z.HasSeveralItems(300, val => val.A%3 == 0)); Assert.IsFalse(z.HasSeveralItems(1025, val => val.A%3 == 0)); Assert.IsTrue(dict.HasSeveralItems(10, val => val.Key%3 == 0)); Assert.IsTrue(dict.HasSeveralItems(300, val => val.Key%3 == 0)); Assert.IsFalse(dict.HasSeveralItems(1025, val => val.Key%3 == 0)); }
public void HasSeveralItemsArray() { var x = Enumerable.Range(1, 1024).ToArray(); var y = Enumerable.Range(1, 1024).Select(a => new Tuple<int, int>(a,a)).ToArray(); var z = Enumerable.Range(1, 1024).Select(a => new { A = a}).ToArray(); var dict = new SortedDictionary<int, int>(x.ToDictionary(a => a, a => a)); Assert.IsTrue(x.HasSeveralItems(10)); Assert.IsTrue(x.HasSeveralItems(1000)); Assert.IsFalse(x.HasSeveralItems(1025)); Assert.IsTrue(y.HasSeveralItems(10)); Assert.IsTrue(y.HasSeveralItems(1000)); Assert.IsFalse(y.HasSeveralItems(1025)); Assert.IsTrue(z.HasSeveralItems(10)); Assert.IsTrue(z.HasSeveralItems(1000)); Assert.IsFalse(z.HasSeveralItems(1025)); Assert.IsTrue(dict.HasSeveralItems(10)); Assert.IsTrue(dict.HasSeveralItems(1000)); Assert.IsFalse(dict.HasSeveralItems(1025)); }