Throw.cs 698 B

123456789101112131415161718192021222324
  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 Throw : AsyncEnumerableExTests
  11. {
  12. [Fact]
  13. public async Task Throw1()
  14. {
  15. var ex = new Exception("Bang!");
  16. var xs = AsyncEnumerableEx.Throw<int>(ex);
  17. var e = xs.GetAsyncEnumerator();
  18. await AssertThrowsAsync(e.MoveNextAsync(), ex);
  19. Assert.False(await e.MoveNextAsync());
  20. }
  21. }
  22. }