Range.cs 1002 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 Range : AsyncEnumerableTests
  10. {
  11. [Fact]
  12. public void Range_Null()
  13. {
  14. AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerable.Range(0, -1));
  15. }
  16. [Fact]
  17. public void Range1()
  18. {
  19. var xs = AsyncEnumerable.Range(2, 5);
  20. var e = xs.GetAsyncEnumerator();
  21. HasNext(e, 2);
  22. HasNext(e, 3);
  23. HasNext(e, 4);
  24. HasNext(e, 5);
  25. HasNext(e, 6);
  26. NoNext(e);
  27. }
  28. [Fact]
  29. public void Range2()
  30. {
  31. var xs = AsyncEnumerable.Range(2, 0);
  32. var e = xs.GetAsyncEnumerator();
  33. NoNext(e);
  34. }
  35. }
  36. }