Tests.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.Collections.Generic;
  6. using Xunit;
  7. namespace Tests
  8. {
  9. public partial class Tests
  10. {
  11. #pragma warning disable xUnit1013 // Public method should be marked as test
  12. public void AssertThrows<E>(Action a)
  13. where E : Exception
  14. {
  15. Assert.Throws<E>(a);
  16. }
  17. public void AssertThrows<E>(Action a, Func<E, bool> assert)
  18. where E : Exception
  19. {
  20. try
  21. {
  22. a();
  23. Assert.True(false);
  24. }
  25. catch (E e)
  26. {
  27. Assert.True(assert(e));
  28. }
  29. }
  30. public void NoNext<T>(IEnumerator<T> e)
  31. {
  32. Assert.False(e.MoveNext());
  33. }
  34. public void HasNext<T>(IEnumerator<T> e, T value)
  35. {
  36. Assert.True(e.MoveNext());
  37. Assert.Equal(value, e.Current);
  38. }
  39. #pragma warning restore xUnit1013 // Public method should be marked as test
  40. }
  41. }