1
0

SelectMany.cs 1.2 KB

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