Merge pull request #1936 from esdrubal/DotNetRelativeOrAbsolute
[mono.git] / mcs / class / corlib / Test / System.Diagnostics.Contracts / Helpers / TestContractBase.cs
1
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using System.Text;
6 using NUnit.Framework;
7 using System.Diagnostics.Contracts;
8 using System.Diagnostics;
9 using System.Reflection;
10 using System.Diagnostics.Contracts.Internal;
11
12 namespace MonoTests.System.Diagnostics.Contracts.Helpers {
13
14         public class TestContractBase {
15
16                 protected TestContractBase() {
17                         // Get the type of System.Diagnostics.Contracts.ContractException
18                         // Have to do this differently depending on how the test is being run.
19                         this.ContractExceptionType = Type.GetType("System.Diagnostics.Contracts.ContractException");
20                         if (this.ContractExceptionType == null) {
21                                 // Special code for when Contracts namespace is not in CorLib
22                                 var mGetContractExceptionType = typeof (Contract).GetMethod ("GetContractExceptionType", BindingFlags.NonPublic | BindingFlags.Static);
23                                 this.ContractExceptionType = (Type) mGetContractExceptionType.Invoke (null, null);
24                         }
25                 }
26
27                 [SetUp]
28                 public void Setup() {
29                         // Remove all event handlers from Contract.ContractFailed
30                         var eventField = typeof(global::System.Runtime.CompilerServices.ContractHelper).GetField("contractFailedEvent", BindingFlags.Static | BindingFlags.NonPublic);
31                         eventField.SetValue(null, null);
32                 }
33
34                 [TearDown]
35                 public void TearDown() {
36                 }
37
38                 protected Type ContractExceptionType { get; private set; }
39
40         }
41 }
42