1 // ParallelEnumerableTests.cs
3 // Copyright (c) 2008 Jérémie "Garuma" Laval
5 // Based on Enumerable test suite by Jb Evain (jbevain@novell.com)
7 // Permission is hereby granted, free of charge, to any person obtaining a copy
8 // of this software and associated documentation files (the "Software"), to deal
9 // in the Software without restriction, including without limitation the rights
10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 // copies of the Software, and to permit persons to whom the Software is
12 // furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 using System.Threading;
33 using System.Collections;
34 using System.Collections.Generic;
36 using NUnit.Framework;
38 namespace MonoTests.System.Linq
40 internal static class AsParallelHelper
42 internal static ParallelQuery<T> AsReallyParallel<T> (this IEnumerable<T> source)
44 return source.AsParallel ().WithExecutionMode (ParallelExecutionMode.ForceParallelism);
48 [TestFixtureAttribute]
49 public class ParallelEnumerableTests
51 IEnumerable<int> baseEnumerable;
56 baseEnumerable = Enumerable.Range(1, 1000);
59 static void AreEquivalent (IEnumerable syncEnumerable, IEnumerable async_resEnumerable)
61 Assert.That (async_resEnumerable, new NUnit.Framework.Constraints.CollectionEquivalentConstraint (syncEnumerable));
64 static void AssertAreSame<T> (IEnumerable<T> expected, IEnumerable<T> actual)
66 if (expected == null) {
67 Assert.IsNull (actual);
71 Assert.IsNotNull (actual);
74 IEnumerator<T> ee = expected.GetEnumerator ();
75 IEnumerator<T> ea = actual.GetEnumerator ();
77 while (ee.MoveNext ()) {
78 Assert.IsTrue (ea.MoveNext (), "'" + ee.Current + "' expected at index '"+ ++index + "'.");
79 Assert.AreEqual (ee.Current, ea.Current, "at index '" + index + "'");
83 Assert.Fail ("Unexpected element: " + ea.Current);
86 public static void AssertException<T> (Action action) where T : Exception
94 Assert.Fail ("Expected: " + typeof (T).Name);
97 static void AssertAreSame<K, V> (K expectedKey, IEnumerable<V> expectedValues, IGrouping<K, V> actual)
99 if (expectedValues == null) {
100 Assert.IsNull (actual);
104 Assert.IsNotNull (actual);
106 Assert.AreEqual (expectedKey, actual.Key);
108 var ee = expectedValues.GetEnumerator ();
109 var ea = actual.GetEnumerator ();
111 while (ee.MoveNext ()) {
112 Assert.IsTrue (ea.MoveNext (), "'" + ee.Current + "' expected.");
113 Assert.AreEqual (ee.Current, ea.Current);
117 Assert.Fail ("Unexpected element: " + ee.Current);
120 static void AssertAreSame<K, V> (IDictionary<K, IEnumerable<V>> expected, IEnumerable<IGrouping<K, V>> actual)
122 if (expected == null) {
123 Assert.IsNull (actual);
127 Assert.IsNotNull (actual);
129 var ee = expected.GetEnumerator ();
130 var ea = actual.GetEnumerator ();
132 while (ee.MoveNext ()) {
133 Assert.IsTrue (ea.MoveNext (), "'" + ee.Current.Key + "' expected.");
134 AssertAreSame (ee.Current.Key, ee.Current.Value, ea.Current);
138 Assert.Fail ("Unexpected element: " + ee.Current.Key);
141 static void AssertAreSame<K, V> (IDictionary<K, IEnumerable<V>> expected, ILookup<K, V> actual)
143 if (expected == null) {
144 Assert.IsNull (actual);
148 Assert.IsNotNull (actual);
150 var ee = expected.GetEnumerator ();
151 var ea = actual.GetEnumerator ();
153 while (ee.MoveNext ()) {
154 Assert.IsTrue (ea.MoveNext (), "'" + ee.Current.Key + "' expected.");
155 AssertAreSame (ee.Current.Key, ee.Current.Value, ea.Current);
159 Assert.Fail ("Unexpected element: " + ee.Current.Key);
162 static void AssertAreSame<K, V> (IDictionary<K, V> expected, IDictionary<K, V> actual)
164 if (expected == null) {
165 Assert.IsNull (actual);
169 Assert.IsNotNull (actual);
171 var ee = expected.GetEnumerator ();
172 var ea = actual.GetEnumerator ();
174 while (ee.MoveNext ()) {
175 Assert.IsTrue (ea.MoveNext (), "'" + ee.Current.Key + ", " + ee.Current.Value + "' expected.");
176 Assert.AreEqual (ee.Current.Key, ea.Current.Key);
177 Assert.AreEqual (ee.Current.Value, ea.Current.Value);
181 Assert.Fail ("Unexpected element: " + ee.Current.Key + ", " + ee.Current.Value);
185 public void SelectTestCase ()
187 ParallelTestHelper.Repeat (() => {
188 IEnumerable<int> sync = baseEnumerable.Select (i => i * i);
189 IEnumerable<int> async_res = baseEnumerable.AsParallel ().Select (i => i * i);
191 AreEquivalent(sync, async_res);
196 public void WhereTestCase ()
198 ParallelTestHelper.Repeat (() => {
199 IEnumerable<int> sync = baseEnumerable.Where(i => i % 2 == 0);
200 IEnumerable<int> async_res = baseEnumerable.AsParallel().Where(i => i % 2 == 0);
202 AreEquivalent(sync, async_res);
207 public void CountTestCase ()
209 ParallelTestHelper.Repeat (() => {
210 int sync = baseEnumerable.Count();
211 int async_res = baseEnumerable.AsParallel().Count();
213 Assert.AreEqual(sync, async_res, "#1");
218 public void AggregateTestCase ()
220 ParallelTestHelper.Repeat (() => {
221 ParallelQuery<int> range = ParallelEnumerable.Repeat (5, 2643);
222 double average = range.Aggregate(() => new double[2],
223 (acc, elem) => { acc[0] += elem; acc[1]++; return acc; },
224 (acc1, acc2) => { acc1[0] += acc2[0]; acc1[1] += acc2[1]; return acc1; },
225 acc => acc[0] / acc[1]);
227 Assert.AreEqual(5.0, average, "#1");
232 public void TestSimpleExcept ()
234 ParallelTestHelper.Repeat (() => {
235 int [] first = {0, 1, 2, 3, 4, 5};
236 int [] second = {2, 4, 6};
237 int [] result = {0, 1, 3, 5};
239 AreEquivalent (result, first.AsReallyParallel ().Except (second.AsParallel ()));
244 public void TestSimpleIntersect ()
246 ParallelTestHelper.Repeat (() => {
247 int [] first = {0, 1, 2, 3, 4, 5};
248 int [] second = {2, 4, 6};
249 int [] result = {2, 4};
251 AreEquivalent (result, first.AsReallyParallel ().Intersect (second.AsParallel ()));
256 public void TestSimpleUnion ()
258 ParallelTestHelper.Repeat (() => {
259 int [] first = {0, 1, 2, 3, 4, 5};
260 int [] second = {2, 4, 6};
261 int [] result = {0, 1, 2, 3, 4, 5, 6};
263 AreEquivalent (result, first.AsReallyParallel ().Union (second.AsParallel ()));
268 public void TestBigUnion ()
270 ParallelTestHelper.Repeat (() => {
271 int [] first = Enumerable.Range (1, 10000).ToArray ();
272 int [] second = Enumerable.Range (323, 757).ToArray ();
274 AreEquivalent (first, first.AsReallyParallel ().Union (second.AsParallel ()));
279 public void TestBigIntersect ()
281 ParallelTestHelper.Repeat (() => {
282 int [] first = Enumerable.Range (1, 10000).ToArray ();
283 int [] second = Enumerable.Range (323, 757).ToArray ();
285 AreEquivalent (second, first.AsReallyParallel ().Intersect (second.AsParallel ()));
293 public void TestCast ()
299 Foo [] foos = new Foo [] {a, b, c};
300 Bar [] result = new Bar [] {a, b, c};
302 AreEquivalent (result, foos.AsReallyParallel ().Cast<Bar> ());
306 public void TestSkip ()
308 int [] data = {0, 1, 2, 3, 4, 5};
309 int [] result = {3, 4, 5};
311 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Skip (3).ToArray ());
315 public void TestSkipIterating ()
317 int [] data = {0, 1, 2, 3, 4, 5};
318 int [] result = {3, 4, 5};
320 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Skip (3));
324 public void TestSkipWhile ()
326 int [] data = {0, 1, 2, 3, 4, 5};
327 int [] result = {3, 4, 5};
329 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().SkipWhile (i => i < 3));
333 public void TestTake ()
335 int [] data = {0, 1, 2, 3, 4, 5};
336 int [] result = {0, 1, 2};
338 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Take (3));
342 public void TestTakeWhile ()
344 int [] data = {0, 1, 2, 3, 4, 5};
345 int [] result = {0, 1, 2};
347 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().TakeWhile (i => i < 3));
351 public void SelectManyTest ()
353 IEnumerable<int> initial = Enumerable.Range (1, 50);
354 IEnumerable<int> expected = initial.SelectMany ((i) => Enumerable.Range (1, i));
356 ParallelTestHelper.Repeat (() => {
357 var actual = initial.AsReallyParallel ().SelectMany ((i) => Enumerable.Range (1, i));
358 AreEquivalent (expected, actual);
363 public void SelectManyOrderedTest ()
365 IEnumerable<int> initial = Enumerable.Range (1, 50);
366 IEnumerable<int> expected = initial.SelectMany ((i) => Enumerable.Range (1, i));
368 ParallelTestHelper.Repeat (() => {
369 var actual = initial.AsReallyParallel ().AsOrdered ().SelectMany ((i) => Enumerable.Range (1, i));
370 AssertAreSame (expected, actual);
375 public void TestLast ()
377 int [] data = {1, 2, 3};
379 Assert.AreEqual (3, data.AsReallyParallel ().AsOrdered ().Last ());
383 public void TestLastOrDefault ()
387 Assert.AreEqual (default (int), data.AsReallyParallel ().AsOrdered ().LastOrDefault ());
391 public void TestFirst ()
393 int [] data = {1, 2, 3};
395 Assert.AreEqual (1, data.AsReallyParallel ().AsOrdered ().First ());
399 public void TestFirstOrDefault ()
403 Assert.AreEqual (default (int), data.AsReallyParallel ().AsOrdered ().FirstOrDefault ());
407 public void TestReverse ()
409 int [] data = {0, 1, 2, 3, 4};
410 int [] result = {4, 3, 2, 1, 0};
412 AssertAreSame (result, ((IEnumerable<int>)data).Select ((i) => i).AsReallyParallel ().AsOrdered ().Reverse ());
413 AssertAreSame (result, ParallelEnumerable.Range (0, 5).AsReallyParallel ().AsOrdered ().Reverse ());
417 public void TestOrderBy ()
419 ParallelTestHelper.Repeat (() => {
420 int [] array = { 14, 53, 3, 9, 11, 14, 5, 32, 2 };
422 var q = array.AsReallyParallel ().OrderBy ((i) => i);
423 AssertIsOrdered (q, array.Length);
434 if (string.IsNullOrEmpty (name))
435 return Age.ToString ();
437 return name + " (" + Age + ")";
443 get { return age + 1; }
446 public Baz (string name, int age)
452 public override int GetHashCode ()
454 return this.Age ^ this.Name.GetHashCode ();
457 public override bool Equals (object obj)
463 return b.Age == this.Age && b.Name == this.Name;
466 public override string ToString ()
472 static IEnumerable<Baz> CreateBazCollection ()
484 public void TestOrderByAgeAscendingTheByNameDescending ()
486 ParallelTestHelper.Repeat (() => {
487 var q = from b in CreateBazCollection ().AsReallyParallel ()
488 orderby b.Age ascending, b.Name descending
491 var expected = new [] {
499 AssertAreSame (expected, q);
504 public int ID { get; set; }
505 public string Name { get; set; }
507 public override string ToString ()
509 return ID + " " + Name;
513 IEnumerable<Data> CreateData ()
516 new Data { ID = 10, Name = "bcd" },
517 new Data { ID = 20, Name = "Abcd" },
518 new Data { ID = 20, Name = "Ab" },
519 new Data { ID = 10, Name = "Zyx" },
524 public void TestOrderByIdDescendingThenByNameAscending ()
526 ParallelTestHelper.Repeat (() => {
527 var q = from d in CreateData ().AsReallyParallel ()
528 orderby d.ID descending, d.Name ascending
531 var list = new List<Data> (q);
533 Assert.AreEqual ("Ab", list [0].Name);
534 Assert.AreEqual ("Abcd", list [1].Name);
535 Assert.AreEqual ("bcd", list [2].Name);
536 Assert.AreEqual ("Zyx", list [3].Name);
540 static void AssertIsOrdered (IEnumerable<int> e, int count)
542 int f = int.MinValue;
545 foreach (int i in e) {
546 Assert.IsTrue (f <= i, string.Format ("{0} <= {1}", f, i));
551 Assert.AreEqual (count, c);
556 public void ElementAtTestCase()
558 //ParallelTestHelper.Repeat (() => {
559 Assert.AreEqual(1, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(0), "#1");
560 Assert.AreEqual(51, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(50), "#2");
561 Assert.AreEqual(489, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(488), "#3");
566 public void TestJoin ()
569 Tuple<int, int>[] outer = Enumerable.Range (1, 50).Select ((i) => Tuple.Create (i, num - 2 * i)).ToArray ();
570 Tuple<int, int>[] inner = Enumerable.Range (1, 50).Reverse ().Select ((i) => Tuple.Create (i, 2 * i)).ToArray ();
572 IEnumerable<int> expected = outer.Join (inner, (e) => e.Item1, (e) => e.Item1, (e1, e2) => e1.Item2 + e2.Item2, EqualityComparer<int>.Default);
574 ParallelTestHelper.Repeat (() => {
575 ParallelQuery<int> actual = outer.AsReallyParallel ().Join (inner.AsParallel (),
578 (e1, e2) => e1.Item2 + e2.Item2,
579 EqualityComparer<int>.Default);
580 AreEquivalent (expected, actual);
585 public void SmallJoinTest ()
587 var items = new [] { 1, 2, 3 };
588 var items2 = new [] { 1, 2, 3, 4 };
589 var actual = items.AsReallyParallel ().Join (items2.AsReallyParallel (), i => i, i => i, (e1, e2) => e1 + e2);
590 AreEquivalent (new[] { 2, 4, 6 }, actual);
594 [Category ("NotWorking")] // Deadlocks randomly
595 public void TestGroupBy ()
598 Tuple<int, int>[] source = Enumerable.Range (0, num).Select ((i) => Tuple.Create (i / 10, i)).ToArray ();
600 ParallelTestHelper.Repeat (() => {
601 ParallelQuery<IGrouping<int, int>> actual = source.AsReallyParallel ().GroupBy ((e) => e.Item1, (e) => e.Item2, EqualityComparer<int>.Default);
602 foreach (var group in actual) {
603 Assert.IsTrue (group.Key >= 0);
604 Assert.IsTrue (group.Key < num / 10);
607 foreach (var e in group) {
609 Assert.IsTrue (e >= group.Key * 10);
610 Assert.IsTrue (e < (group.Key + 1) * 10);
613 Assert.AreEqual (10, count, "count");
619 public void TakeTestCase()
621 ParallelTestHelper.Repeat (() => {
622 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().AsOrdered ().Take(800);
623 IEnumerable<int> sync = baseEnumerable.Take(800);
625 AreEquivalent(sync, async_res);
627 async_res = baseEnumerable.AsReallyParallel ().AsOrdered ().Take(100);
628 sync = baseEnumerable.Take(100);
630 AreEquivalent(sync, async_res);
635 public void UnorderedTakeTestCase()
637 ParallelTestHelper.Repeat (() => {
638 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().Take(800);
639 IEnumerable<int> sync = baseEnumerable.Take (800);
641 Assert.AreEqual (sync.Count (), async_res.Count (), "#1");
643 async_res = baseEnumerable.AsReallyParallel ().Take(100);
644 sync = baseEnumerable.Take(100);
646 Assert.AreEqual (sync.Count (), async_res.Count (), "#2");
651 public void SkipTestCase()
653 ParallelTestHelper.Repeat (() => {
654 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().AsOrdered().Skip (800);
655 IEnumerable<int> sync = baseEnumerable.Skip (800);
657 AreEquivalent (sync, async_res);
662 public void SkipTestCaseSmall ()
664 ParallelTestHelper.Repeat (() => {
665 var async_res = baseEnumerable.AsReallyParallel ().Skip(100);
666 var sync = baseEnumerable.Skip(100);
668 Assert.AreEqual (sync.Count (), async_res.Count ());
673 public void ZipTestCase()
675 ParallelTestHelper.Repeat (() => {
676 ParallelQuery<int> async_res1 = ParallelEnumerable.Range(0, 10000);
677 ParallelQuery<int> async_res2 = ParallelEnumerable.Repeat(1, 10000).Zip(async_res1, (e1, e2) => e1 + e2);
679 int[] expected = Enumerable.Range (1, 10000).ToArray ();
680 AreEquivalent(expected, Enumerable.ToArray (async_res2));
687 ParallelTestHelper.Repeat (() => {
688 IEnumerable<int> sync = Enumerable.Range(1, 1000);
689 IEnumerable<int> async_res = ParallelEnumerable.Range(1, 1000);
691 AreEquivalent (sync, async_res);
696 public void Range_StartOffset ()
698 ParallelTestHelper.Repeat (() => {
699 IEnumerable<int> sync = Enumerable.Range (30, 10);
700 IEnumerable<int> async_res = ParallelEnumerable.Range (30, 10);
702 AreEquivalent (sync, async_res);
707 public void RepeatTestCase ()
709 ParallelTestHelper.Repeat (() => {
710 IEnumerable<int> sync = Enumerable.Repeat(1, 1000);
711 IEnumerable<int> async_res = ParallelEnumerable.Repeat(1, 1000);
713 AreEquivalent (sync, async_res);
718 public void TestSum ()
720 int [] data = {1, 2, 3, 4};
722 Assert.AreEqual (10, data.AsReallyParallel ().Sum ());
726 public void SumOnEmpty ()
730 Assert.AreEqual (0, data.AsReallyParallel ().Sum ());
734 public void TestMax ()
736 int [] data = {1, 3, 5, 2};
738 Assert.AreEqual (5, data.AsReallyParallel ().Max ());
742 public void TestMin ()
744 int [] data = {3, 5, 2, 6, 1, 7};
746 Assert.AreEqual (1, data.AsReallyParallel ().Min ());
750 public void TestToListOrdered ()
752 int [] data = { 2, 3, 5 };
754 var list = data.AsParallel().AsOrdered().WithExecutionMode (ParallelExecutionMode.ForceParallelism).ToList ();
756 AssertAreSame (data, list);
757 AssertIsOrdered (list, data.Length);
759 Assert.AreEqual (typeof (List<int>), list.GetType ());
763 public void TestToArrayOrdered ()
765 ICollection<int> coll = new List<int> ();
770 int [] result = {0, 1, 2};
772 var array = coll.AsReallyParallel ().AsOrdered().ToArray ();
774 AssertAreSame (result, array);
775 AssertIsOrdered (array, result.Length);
777 Assert.AreEqual (typeof (int []), array.GetType ());
779 array = Enumerable.Range (1, 100).Select ((i) => i).AsReallyParallel ().AsOrdered().ToArray ();
780 result = Enumerable.Range (1, 100).ToArray ();
782 AssertAreSame (result, array);
783 AssertIsOrdered (array, result.Length);
785 Assert.AreEqual (typeof (int []), array.GetType ());
790 public void TestToList ()
792 int [] data = {3, 5, 2};
794 var list = data.AsReallyParallel ().ToList ();
796 AreEquivalent (data, list);
798 Assert.AreEqual (typeof (List<int>), list.GetType ());
802 public void TestToArray ()
804 ICollection<int> coll = new List<int> ();
809 int [] result = {0, 1, 2};
811 var array = coll.AsReallyParallel ().ToArray ();
813 AreEquivalent (result, array);
815 Assert.AreEqual (typeof (int []), array.GetType ());
820 public void TestAverageOnInt32 ()
822 Assert.AreEqual (23.25, (new int [] { 24, 7, 28, 34 }).Average ());
826 public void TestAverageOnInt64 ()
828 Assert.AreEqual (23.25, (new long [] { 24, 7, 28, 34 }).Average ());
833 public void AnyArgumentNullTest ()
835 string [] data = { "2", "1", "5", "3", "4" };
839 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().Any (); });
841 // Any<TSource> (Func<TSource, bool>)
842 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().Any (x => true); });
843 AssertException<ArgumentNullException> (delegate () { data.AsReallyParallel ().Any ((Func<string, bool>) null); });
847 public void AnyTest ()
849 int [] data = { 5, 2, 3, 1, 6 };
854 Assert.IsTrue (data.AsReallyParallel ().Any ());
855 Assert.IsFalse (empty.AsReallyParallel ().Any ());
857 // Any<TSource> (Func<TSource, bool>)
858 Assert.IsTrue (data.AsReallyParallel ().Any (x => x == 5));
859 Assert.IsFalse (data.AsReallyParallel ().Any (x => x == 9));
860 Assert.IsFalse (empty.AsReallyParallel ().Any (x => true));
865 public void AllArgumentNullTest ()
867 string [] data = { "2", "1", "5", "3", "4" };
869 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().All (x => true); });
870 AssertException<ArgumentNullException> (delegate () { data.AsReallyParallel ().All ((Func<string, bool>) null); });
874 public void AllTest ()
876 int [] data = { 5, 2, 3, 1, 6 };
879 Assert.IsTrue (data.AsReallyParallel ().All (x => true));
880 Assert.IsFalse (data.AsReallyParallel ().All (x => x != 1));
881 Assert.IsTrue (empty.AsReallyParallel ().All (x => false));
885 public void SequenceEqualsTest ()
887 var data1 = new int[] { 1, 2, 3 };
888 var data2 = new int[] { 1, 2, 4 };
889 var data3 = new int[] { 1, 2, 3, 4 };
891 Assert.IsTrue (data1.AsReallyParallel ().SequenceEqual (data1.AsReallyParallel ()));
892 Assert.IsTrue (data2.AsReallyParallel ().SequenceEqual (data2.AsReallyParallel ()));
893 Assert.IsTrue (data3.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
894 Assert.IsFalse (data1.AsReallyParallel ().SequenceEqual (data2.AsReallyParallel ()));
895 Assert.IsFalse (data1.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
896 Assert.IsFalse (data2.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
900 public void ContainsTest ()
902 var data1 = new int[] { 1, 2, 3 };
903 var data2 = new int[] { 1, 2, 4 };
904 var data3 = new int[] { 1, 2, 3, 4 };
906 Assert.IsTrue (data1.AsReallyParallel ().Contains (3));
907 Assert.IsFalse (data2.AsReallyParallel ().Contains (3));
908 Assert.IsTrue (data3.AsReallyParallel ().Contains (3));
909 Assert.IsFalse (data3.AsReallyParallel ().Contains (5));
910 Assert.IsTrue (data2.AsReallyParallel ().Contains (2));