Tests.cs 1.1 KB

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