Tests.cs 1.2 KB

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