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 var expected = first;
275 var actual = first.AsReallyParallel ().Union (second.AsParallel ()).ToArray ();
276 // Work around quadratic behavior in NUnitLite's CollectionTally class
277 Array.Sort (expected);
279 AreEquivalent (expected, actual);
284 public void TestBigIntersect ()
286 ParallelTestHelper.Repeat (() => {
287 int [] first = Enumerable.Range (1, 10000).ToArray ();
288 int [] second = Enumerable.Range (323, 757).ToArray ();
290 AreEquivalent (second, first.AsReallyParallel ().Intersect (second.AsParallel ()));
298 public void TestCast ()
304 Foo [] foos = new Foo [] {a, b, c};
305 Bar [] result = new Bar [] {a, b, c};
307 AreEquivalent (result, foos.AsReallyParallel ().Cast<Bar> ());
311 public void TestSkip ()
313 int [] data = {0, 1, 2, 3, 4, 5};
314 int [] result = {3, 4, 5};
316 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Skip (3).ToArray ());
320 public void TestSkipIterating ()
322 int [] data = {0, 1, 2, 3, 4, 5};
323 int [] result = {3, 4, 5};
325 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Skip (3));
329 public void TestSkipWhile ()
331 int [] data = {0, 1, 2, 3, 4, 5};
332 int [] result = {3, 4, 5};
334 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().SkipWhile (i => i < 3));
338 public void TestTake ()
340 int [] data = {0, 1, 2, 3, 4, 5};
341 int [] result = {0, 1, 2};
343 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().Take (3));
347 public void TestTakeWhile ()
349 int [] data = {0, 1, 2, 3, 4, 5};
350 int [] result = {0, 1, 2};
352 AssertAreSame (result, data.AsReallyParallel ().AsOrdered ().TakeWhile (i => i < 3));
356 public void SelectManyTest ()
358 IEnumerable<int> initial = Enumerable.Range (1, 50);
359 IEnumerable<int> expected = initial.SelectMany ((i) => Enumerable.Range (1, i));
361 ParallelTestHelper.Repeat (() => {
362 var actual = initial.AsReallyParallel ().SelectMany ((i) => Enumerable.Range (1, i));
363 AreEquivalent (expected, actual);
368 public void SelectManyOrderedTest ()
370 IEnumerable<int> initial = Enumerable.Range (1, 50);
371 IEnumerable<int> expected = initial.SelectMany ((i) => Enumerable.Range (1, i));
373 ParallelTestHelper.Repeat (() => {
374 var actual = initial.AsReallyParallel ().AsOrdered ().SelectMany ((i) => Enumerable.Range (1, i));
375 AssertAreSame (expected, actual);
380 public void TestLast ()
382 int [] data = {1, 2, 3};
384 Assert.AreEqual (3, data.AsReallyParallel ().AsOrdered ().Last ());
388 public void TestLastOrDefault ()
392 Assert.AreEqual (default (int), data.AsReallyParallel ().AsOrdered ().LastOrDefault ());
396 public void TestFirst ()
398 int [] data = {1, 2, 3};
400 Assert.AreEqual (1, data.AsReallyParallel ().AsOrdered ().First ());
404 public void TestFirstOrDefault ()
408 Assert.AreEqual (default (int), data.AsReallyParallel ().AsOrdered ().FirstOrDefault ());
412 public void TestReverse ()
414 int [] data = {0, 1, 2, 3, 4};
415 int [] result = {4, 3, 2, 1, 0};
417 AssertAreSame (result, ((IEnumerable<int>)data).Select ((i) => i).AsReallyParallel ().AsOrdered ().Reverse ());
418 AssertAreSame (result, ParallelEnumerable.Range (0, 5).AsReallyParallel ().AsOrdered ().Reverse ());
422 public void TestOrderBy ()
424 ParallelTestHelper.Repeat (() => {
425 int [] array = { 14, 53, 3, 9, 11, 14, 5, 32, 2 };
427 var q = array.AsReallyParallel ().OrderBy ((i) => i);
428 AssertIsOrdered (q, array.Length);
439 if (string.IsNullOrEmpty (name))
440 return Age.ToString ();
442 return name + " (" + Age + ")";
448 get { return age + 1; }
451 public Baz (string name, int age)
457 public override int GetHashCode ()
459 return this.Age ^ this.Name.GetHashCode ();
462 public override bool Equals (object obj)
468 return b.Age == this.Age && b.Name == this.Name;
471 public override string ToString ()
477 static IEnumerable<Baz> CreateBazCollection ()
489 public void TestOrderByAgeAscendingTheByNameDescending ()
491 ParallelTestHelper.Repeat (() => {
492 var q = from b in CreateBazCollection ().AsReallyParallel ()
493 orderby b.Age ascending, b.Name descending
496 var expected = new [] {
504 AssertAreSame (expected, q);
509 public int ID { get; set; }
510 public string Name { get; set; }
512 public override string ToString ()
514 return ID + " " + Name;
518 IEnumerable<Data> CreateData ()
521 new Data { ID = 10, Name = "bcd" },
522 new Data { ID = 20, Name = "Abcd" },
523 new Data { ID = 20, Name = "Ab" },
524 new Data { ID = 10, Name = "Zyx" },
529 public void TestOrderByIdDescendingThenByNameAscending ()
531 ParallelTestHelper.Repeat (() => {
532 var q = from d in CreateData ().AsReallyParallel ()
533 orderby d.ID descending, d.Name ascending
536 var list = new List<Data> (q);
538 Assert.AreEqual ("Ab", list [0].Name);
539 Assert.AreEqual ("Abcd", list [1].Name);
540 Assert.AreEqual ("bcd", list [2].Name);
541 Assert.AreEqual ("Zyx", list [3].Name);
545 static void AssertIsOrdered (IEnumerable<int> e, int count)
547 int f = int.MinValue;
550 foreach (int i in e) {
551 Assert.IsTrue (f <= i, string.Format ("{0} <= {1}", f, i));
556 Assert.AreEqual (count, c);
561 public void ElementAtTestCase()
563 //ParallelTestHelper.Repeat (() => {
564 Assert.AreEqual(1, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(0), "#1");
565 Assert.AreEqual(51, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(50), "#2");
566 Assert.AreEqual(489, baseEnumerable.AsReallyParallel ().AsOrdered ().ElementAt(488), "#3");
571 public void TestJoin ()
574 Tuple<int, int>[] outer = Enumerable.Range (1, 50).Select ((i) => Tuple.Create (i, num - 2 * i)).ToArray ();
575 Tuple<int, int>[] inner = Enumerable.Range (1, 50).Reverse ().Select ((i) => Tuple.Create (i, 2 * i)).ToArray ();
577 IEnumerable<int> expected = outer.Join (inner, (e) => e.Item1, (e) => e.Item1, (e1, e2) => e1.Item2 + e2.Item2, EqualityComparer<int>.Default);
579 ParallelTestHelper.Repeat (() => {
580 ParallelQuery<int> actual = outer.AsReallyParallel ().Join (inner.AsParallel (),
583 (e1, e2) => e1.Item2 + e2.Item2,
584 EqualityComparer<int>.Default);
585 AreEquivalent (expected, actual);
590 public void SmallJoinTest ()
592 var items = new [] { 1, 2, 3 };
593 var items2 = new [] { 1, 2, 3, 4 };
594 var actual = items.AsReallyParallel ().Join (items2.AsReallyParallel (), i => i, i => i, (e1, e2) => e1 + e2);
595 AreEquivalent (new[] { 2, 4, 6 }, actual);
599 [Category ("NotWorking")] // Deadlocks randomly
600 public void TestGroupBy ()
603 Tuple<int, int>[] source = Enumerable.Range (0, num).Select ((i) => Tuple.Create (i / 10, i)).ToArray ();
605 ParallelTestHelper.Repeat (() => {
606 ParallelQuery<IGrouping<int, int>> actual = source.AsReallyParallel ().GroupBy ((e) => e.Item1, (e) => e.Item2, EqualityComparer<int>.Default);
607 foreach (var group in actual) {
608 Assert.IsTrue (group.Key >= 0);
609 Assert.IsTrue (group.Key < num / 10);
612 foreach (var e in group) {
614 Assert.IsTrue (e >= group.Key * 10);
615 Assert.IsTrue (e < (group.Key + 1) * 10);
618 Assert.AreEqual (10, count, "count");
624 public void TakeTestCase()
626 ParallelTestHelper.Repeat (() => {
627 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().AsOrdered ().Take(800);
628 IEnumerable<int> sync = baseEnumerable.Take(800);
630 AreEquivalent(sync, async_res);
632 async_res = baseEnumerable.AsReallyParallel ().AsOrdered ().Take(100);
633 sync = baseEnumerable.Take(100);
635 AreEquivalent(sync, async_res);
640 public void UnorderedTakeTestCase()
642 ParallelTestHelper.Repeat (() => {
643 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().Take(800);
644 IEnumerable<int> sync = baseEnumerable.Take (800);
646 Assert.AreEqual (sync.Count (), async_res.Count (), "#1");
648 async_res = baseEnumerable.AsReallyParallel ().Take(100);
649 sync = baseEnumerable.Take(100);
651 Assert.AreEqual (sync.Count (), async_res.Count (), "#2");
656 public void SkipTestCase()
658 ParallelTestHelper.Repeat (() => {
659 ParallelQuery<int> async_res = baseEnumerable.AsReallyParallel ().AsOrdered().Skip (800);
660 IEnumerable<int> sync = baseEnumerable.Skip (800);
662 AreEquivalent (sync, async_res);
667 public void SkipTestCaseSmall ()
669 ParallelTestHelper.Repeat (() => {
670 var async_res = baseEnumerable.AsReallyParallel ().Skip(100);
671 var sync = baseEnumerable.Skip(100);
673 Assert.AreEqual (sync.Count (), async_res.Count ());
678 public void ZipTestCase()
680 ParallelTestHelper.Repeat (() => {
681 ParallelQuery<int> async_res1 = ParallelEnumerable.Range(0, 10000);
682 ParallelQuery<int> async_res2 = ParallelEnumerable.Repeat(1, 10000).Zip(async_res1, (e1, e2) => e1 + e2);
684 int[] expected = Enumerable.Range (1, 10000).ToArray ();
685 var actual = Enumerable.ToArray (async_res2);
686 // Work around quadratic behavior in NUnitLite's CollectionTally class
687 Array.Sort (expected);
689 AreEquivalent(expected, actual);
696 ParallelTestHelper.Repeat (() => {
697 IEnumerable<int> sync = Enumerable.Range(1, 1000);
698 IEnumerable<int> async_res = ParallelEnumerable.Range(1, 1000);
700 AreEquivalent (sync, async_res);
705 public void Range_StartOffset ()
707 ParallelTestHelper.Repeat (() => {
708 IEnumerable<int> sync = Enumerable.Range (30, 10);
709 IEnumerable<int> async_res = ParallelEnumerable.Range (30, 10);
711 AreEquivalent (sync, async_res);
716 public void RepeatTestCase ()
718 ParallelTestHelper.Repeat (() => {
719 IEnumerable<int> sync = Enumerable.Repeat(1, 1000);
720 IEnumerable<int> async_res = ParallelEnumerable.Repeat(1, 1000);
722 AreEquivalent (sync, async_res);
727 public void TestSum ()
729 int [] data = {1, 2, 3, 4};
731 Assert.AreEqual (10, data.AsReallyParallel ().Sum ());
735 public void SumOnEmpty ()
739 Assert.AreEqual (0, data.AsReallyParallel ().Sum ());
743 public void TestMax ()
745 int [] data = {1, 3, 5, 2};
747 Assert.AreEqual (5, data.AsReallyParallel ().Max ());
751 public void TestMin ()
753 int [] data = {3, 5, 2, 6, 1, 7};
755 Assert.AreEqual (1, data.AsReallyParallel ().Min ());
759 public void TestToListOrdered ()
761 int [] data = { 2, 3, 5 };
763 var list = data.AsParallel().AsOrdered().WithExecutionMode (ParallelExecutionMode.ForceParallelism).ToList ();
765 AssertAreSame (data, list);
766 AssertIsOrdered (list, data.Length);
768 Assert.AreEqual (typeof (List<int>), list.GetType ());
772 public void TestToArrayOrdered ()
774 ICollection<int> coll = new List<int> ();
779 int [] result = {0, 1, 2};
781 var array = coll.AsReallyParallel ().AsOrdered().ToArray ();
783 AssertAreSame (result, array);
784 AssertIsOrdered (array, result.Length);
786 Assert.AreEqual (typeof (int []), array.GetType ());
788 array = Enumerable.Range (1, 100).Select ((i) => i).AsReallyParallel ().AsOrdered().ToArray ();
789 result = Enumerable.Range (1, 100).ToArray ();
791 AssertAreSame (result, array);
792 AssertIsOrdered (array, result.Length);
794 Assert.AreEqual (typeof (int []), array.GetType ());
799 public void TestToList ()
801 int [] data = {3, 5, 2};
803 var list = data.AsReallyParallel ().ToList ();
805 AreEquivalent (data, list);
807 Assert.AreEqual (typeof (List<int>), list.GetType ());
811 public void TestToArray ()
813 ICollection<int> coll = new List<int> ();
818 int [] result = {0, 1, 2};
820 var array = coll.AsReallyParallel ().ToArray ();
822 AreEquivalent (result, array);
824 Assert.AreEqual (typeof (int []), array.GetType ());
829 public void TestAverageOnInt32 ()
831 Assert.AreEqual (23.25, (new int [] { 24, 7, 28, 34 }).Average ());
835 public void TestAverageOnInt64 ()
837 Assert.AreEqual (23.25, (new long [] { 24, 7, 28, 34 }).Average ());
842 public void AnyArgumentNullTest ()
844 string [] data = { "2", "1", "5", "3", "4" };
848 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().Any (); });
850 // Any<TSource> (Func<TSource, bool>)
851 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().Any (x => true); });
852 AssertException<ArgumentNullException> (delegate () { data.AsReallyParallel ().Any ((Func<string, bool>) null); });
856 public void AnyTest ()
858 int [] data = { 5, 2, 3, 1, 6 };
863 Assert.IsTrue (data.AsReallyParallel ().Any ());
864 Assert.IsFalse (empty.AsReallyParallel ().Any ());
866 // Any<TSource> (Func<TSource, bool>)
867 Assert.IsTrue (data.AsReallyParallel ().Any (x => x == 5));
868 Assert.IsFalse (data.AsReallyParallel ().Any (x => x == 9));
869 Assert.IsFalse (empty.AsReallyParallel ().Any (x => true));
874 public void AllArgumentNullTest ()
876 string [] data = { "2", "1", "5", "3", "4" };
878 AssertException<ArgumentNullException> (delegate () { ((IEnumerable<string>) null).AsReallyParallel ().All (x => true); });
879 AssertException<ArgumentNullException> (delegate () { data.AsReallyParallel ().All ((Func<string, bool>) null); });
883 public void AllTest ()
885 int [] data = { 5, 2, 3, 1, 6 };
888 Assert.IsTrue (data.AsReallyParallel ().All (x => true));
889 Assert.IsFalse (data.AsReallyParallel ().All (x => x != 1));
890 Assert.IsTrue (empty.AsReallyParallel ().All (x => false));
894 public void SequenceEqualsTest ()
896 var data1 = new int[] { 1, 2, 3 };
897 var data2 = new int[] { 1, 2, 4 };
898 var data3 = new int[] { 1, 2, 3, 4 };
900 Assert.IsTrue (data1.AsReallyParallel ().SequenceEqual (data1.AsReallyParallel ()));
901 Assert.IsTrue (data2.AsReallyParallel ().SequenceEqual (data2.AsReallyParallel ()));
902 Assert.IsTrue (data3.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
903 Assert.IsFalse (data1.AsReallyParallel ().SequenceEqual (data2.AsReallyParallel ()));
904 Assert.IsFalse (data1.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
905 Assert.IsFalse (data2.AsReallyParallel ().SequenceEqual (data3.AsReallyParallel ()));
909 public void ContainsTest ()
911 var data1 = new int[] { 1, 2, 3 };
912 var data2 = new int[] { 1, 2, 4 };
913 var data3 = new int[] { 1, 2, 3, 4 };
915 Assert.IsTrue (data1.AsReallyParallel ().Contains (3));
916 Assert.IsFalse (data2.AsReallyParallel ().Contains (3));
917 Assert.IsTrue (data3.AsReallyParallel ().Contains (3));
918 Assert.IsFalse (data3.AsReallyParallel ().Contains (5));
919 Assert.IsTrue (data2.AsReallyParallel ().Contains (2));