CreateEnumerator.cs 919 B

123456789101112131415161718192021222324252627282930
  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.Collections.Generic;
  6. using System.Threading.Tasks;
  7. using Xunit;
  8. namespace Tests
  9. {
  10. public class CreateEnumerator : AsyncEnumerableTests
  11. {
  12. [Fact]
  13. public void CreateEnumerator_Null()
  14. {
  15. Assert.Throws<ArgumentNullException>(() => AsyncEnumerator.Create(default, () => 3, () => new ValueTask()));
  16. }
  17. [Fact]
  18. public void CreateEnumerator_Throws()
  19. {
  20. var iter = AsyncEnumerator.Create(() => new ValueTask<bool>(false), () => 3, () => new ValueTask());
  21. var enu = (IAsyncEnumerable<int>)iter;
  22. Assert.Throws<NotSupportedException>(() => enu.GetAsyncEnumerator());
  23. }
  24. }
  25. }