Never.cs 791 B

1234567891011121314151617181920212223242526272829
  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 Never : AsyncEnumerableExTests
  11. {
  12. [Fact]
  13. public async Task Never1()
  14. {
  15. var xs = AsyncEnumerableEx.Never<int>();
  16. var e = xs.GetAsyncEnumerator();
  17. Assert.False(e.MoveNextAsync().IsCompleted); // Very rudimentary check
  18. AssertThrows<InvalidOperationException>(() => Nop(e.Current));
  19. await e.DisposeAsync();
  20. }
  21. private void Nop(object o)
  22. {
  23. }
  24. }
  25. }