NUnitMoonHelper.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Helper to allow 'same source' unit tests from Moonlight to be executed under NUnit
  2. using System;
  3. using NUnit.Framework;
  4. namespace Mono.Moonlight.UnitTesting {
  5. public class MoonlightBugAttribute : IgnoreAttribute {
  6. }
  7. }
  8. namespace Microsoft.VisualStudio.TestTools.UnitTesting {
  9. public class TestClassAttribute : TestFixtureAttribute {
  10. }
  11. public class TestMethodAttribute : TestAttribute {
  12. }
  13. public class Assert : NUnit.Framework.Assert {
  14. public static void Throws<TException> (Action code, string message) where TException : Exception
  15. {
  16. Type expected_exception = typeof (TException);
  17. bool failed = false;
  18. try {
  19. code ();
  20. failed = true;
  21. }
  22. catch (Exception ex) {
  23. if (!(ex.GetType () == expected_exception))
  24. Assert.Fail (string.Format ("Expected '{0}', got '{1}'. {2}", expected_exception.FullName, ex.GetType ().FullName, message));
  25. }
  26. if (failed)
  27. Assert.Fail (string.Format ("Expected '{0}', but got no exception. {1}", expected_exception.FullName, message));
  28. }
  29. }
  30. }