Tests.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
  2. using System;
  3. using System.Text;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using Microsoft.VisualStudio.TestTools.UnitTesting;
  7. namespace Tests
  8. {
  9. [TestClass]
  10. public partial class Tests
  11. {
  12. public void AssertThrows<E>(Action a)
  13. where E : Exception
  14. {
  15. try
  16. {
  17. a();
  18. Assert.Fail();
  19. }
  20. catch (E)
  21. {
  22. }
  23. }
  24. public void AssertThrows<E>(Action a, Func<E, bool> assert)
  25. where E : Exception
  26. {
  27. try
  28. {
  29. a();
  30. Assert.Fail();
  31. }
  32. catch (E e)
  33. {
  34. Assert.IsTrue(assert(e));
  35. }
  36. }
  37. public void NoNext<T>(IEnumerator<T> e)
  38. {
  39. Assert.IsFalse(e.MoveNext());
  40. }
  41. public void HasNext<T>(IEnumerator<T> e, T value)
  42. {
  43. Assert.IsTrue(e.MoveNext());
  44. Assert.AreEqual(value, e.Current);
  45. }
  46. }
  47. }