Throw.cs 752 B

12345678910111213141516171819202122232425262728
  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 Xunit;
  6. namespace Tests
  7. {
  8. public class Throw : AsyncEnumerableTests
  9. {
  10. [Fact]
  11. public void Throw_Null()
  12. {
  13. Assert.Throws<ArgumentNullException>(() => Throw<int>(default));
  14. }
  15. [Fact]
  16. public async System.Threading.Tasks.Task Throw1Async()
  17. {
  18. var ex = new Exception("Bang");
  19. var xs = Throw<int>(ex);
  20. var e = xs.GetAsyncEnumerator();
  21. await AssertThrowsAsync(e.MoveNextAsync(), ex);
  22. }
  23. }
  24. }