3 using System.Collections.Generic;
7 using System.Diagnostics.Contracts;
8 using System.Diagnostics;
9 using System.Reflection;
10 using System.Diagnostics.Contracts.Internal;
12 namespace MonoTests.System.Diagnostics.Contracts.Helpers {
14 public class TestContractBase {
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);
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);
35 public void TearDown() {
38 protected Type ContractExceptionType { get; private set; }