SelectMany.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the Apache 2.0 License.
  3. // See the LICENSE file in the project root for more information.
  4. using System;
  5. using System.Linq;
  6. using Xunit;
  7. namespace Tests
  8. {
  9. public class SelectMany : AsyncEnumerableExTests
  10. {
  11. [Fact]
  12. public void SelectMany_Null()
  13. {
  14. Assert.Throws<ArgumentNullException>(() => AsyncEnumerableEx.SelectMany<int, int>(default, Return42));
  15. Assert.Throws<ArgumentNullException>(() => AsyncEnumerableEx.SelectMany<int, int>(Return42, default));
  16. }
  17. [Fact]
  18. public async System.Threading.Tasks.Task SelectMany1Async()
  19. {
  20. var xs = new[] { 0, 1, 2 }.ToAsyncEnumerable();
  21. var ys = new[] { 3, 4 }.ToAsyncEnumerable();
  22. var res = xs.SelectMany(ys);
  23. var e = res.GetAsyncEnumerator();
  24. await HasNextAsync(e, 3);
  25. await HasNextAsync(e, 4);
  26. await HasNextAsync(e, 3);
  27. await HasNextAsync(e, 4);
  28. await HasNextAsync(e, 3);
  29. await HasNextAsync(e, 4);
  30. await NoNextAsync(e);
  31. }
  32. }
  33. }