Tests.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 Xunit;
  7. namespace Tests
  8. {
  9. public partial class Tests
  10. {
  11. public void AssertThrows<E>(Action a)
  12. where E : Exception
  13. {
  14. Assert.Throws<E>(a);
  15. }
  16. public void AssertThrows<E>(Action a, Func<E, bool> assert)
  17. where E : Exception
  18. {
  19. try
  20. {
  21. a();
  22. Assert.True(false);
  23. }
  24. catch (E e)
  25. {
  26. Assert.True(assert(e));
  27. }
  28. }
  29. public void NoNext<T>(IEnumerator<T> e)
  30. {
  31. Assert.False(e.MoveNext());
  32. }
  33. public void HasNext<T>(IEnumerator<T> e, T value)
  34. {
  35. Assert.True(e.MoveNext());
  36. Assert.Equal(value, e.Current);
  37. }
  38. }
  39. }