Merge pull request #93 from konrad-kruczynski/dispatcher_timer_fix
[mono.git] / mcs / class / System.ServiceModel / Test / NUnitMoonHelper.cs
1 // Helper to allow 'same source' unit tests from Moonlight to be executed under NUnit
2
3 using System;
4 using NUnit.Framework;
5
6 namespace Mono.Moonlight.UnitTesting {
7
8         public class MoonlightBugAttribute : IgnoreAttribute {
9         }
10 }
11
12 namespace Microsoft.VisualStudio.TestTools.UnitTesting {
13
14         public class TestClassAttribute : TestFixtureAttribute {
15         }
16
17         public class TestMethodAttribute : TestAttribute {
18         }
19
20         public class Assert : NUnit.Framework.Assert {
21
22                 public static void Throws<TException> (Action code, string message) where TException : Exception
23                 {
24                         Type expected_exception = typeof (TException);
25                         bool failed = false;
26                         try {
27                                 code ();
28                                 failed = true;
29                         }
30                         catch (Exception ex) {
31                                 if (!(ex.GetType () == expected_exception))
32                                         Assert.Fail (string.Format ("Expected '{0}', got '{1}'. {2}", expected_exception.FullName, ex.GetType ().FullName, message));
33                         }
34                         if (failed)
35                                 Assert.Fail (string.Format ("Expected '{0}', but got no exception. {1}", expected_exception.FullName, message));
36                 }
37         }
38 }
39