Repeat.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 System.Threading.Tasks;
  7. using Xunit;
  8. namespace Tests
  9. {
  10. public class Repeat : AsyncEnumerableTests
  11. {
  12. [Fact]
  13. public void Repeat_Null()
  14. {
  15. AssertThrows<ArgumentOutOfRangeException>(() => AsyncEnumerable.Repeat(0, -1));
  16. }
  17. [Fact]
  18. public void Repeat1()
  19. {
  20. var xs = AsyncEnumerable.Repeat(2, 5);
  21. var e = xs.GetAsyncEnumerator();
  22. HasNext(e, 2);
  23. HasNext(e, 2);
  24. HasNext(e, 2);
  25. HasNext(e, 2);
  26. HasNext(e, 2);
  27. NoNext(e);
  28. }
  29. [Fact]
  30. public void Repeat2()
  31. {
  32. var xs = AsyncEnumerable.Repeat(2, 0);
  33. var e = xs.GetAsyncEnumerator();
  34. NoNext(e);
  35. }
  36. }
  37. }