public static void SingleOrDefault(Labeled <ParallelQuery <int> > labeled, int count, int element) { ParallelQuery <int> query = labeled.Item; Assert.Equal(count >= 1 ? element : default(int), query.SingleOrDefault()); Assert.Equal(count >= 1 ? element : default(int), query.SingleOrDefault(x => true)); }
public static void SingleOrDefault_NoMatch(Labeled <ParallelQuery <int> > labeled, int count, int element) { ParallelQuery <int> query = labeled.Item; IntegerRangeSet seen = new IntegerRangeSet(0, count); Assert.Equal(default(int), query.SingleOrDefault(x => !seen.Add(x))); seen.AssertComplete(); }
public static void SingleOrDefault_AllMatch(Labeled <ParallelQuery <int> > labeled, int count, int element) { ParallelQuery <int> query = labeled.Item; Assert.Throws <InvalidOperationException>(() => query.SingleOrDefault(x => true)); }