[bcl] Remove NET_4_0 defines from class libs
[mono.git] / mcs / class / corlib / Test / System.Diagnostics.Contracts / ContractMarkerMethodsTest.cs
1
2 #define CONTRACTS_FULL
3 #define DEBUG
4
5 using System;
6 using System.Collections.Generic;
7 using System.Linq;
8 using System.Text;
9 using NUnit.Framework;
10 using System.Diagnostics.Contracts;
11 using MonoTests.System.Diagnostics.Contracts.Helpers;
12
13 namespace MonoTests.System.Diagnostics.Contracts {
14
15         [TestFixture]
16         public class ContractMarkerMethodsTest : TestContractBase {
17
18                 /// <summary>
19                 /// Contract.EndContractBlock() has no effects.
20                 /// </summary>
21                 [Test, RunAgainstReference]
22                 public void TestEndContractBlock ()
23                 {
24                         Contract.EndContractBlock ();
25                 }
26
27                 /// <summary>
28                 /// Contract.OldValue() has no effect, and always returns the default value for the type.
29                 /// </summary>
30                 [Test, RunAgainstReference]
31                 public void TestOldValue ()
32                 {
33                         int i = Contract.OldValue<int> (8);
34                         object o = Contract.OldValue<object> (new object ());
35
36                         Assert.AreEqual (0, i, "TestOldValue() int value wrong");
37                         Assert.IsNull (o, "TestOldValue() object value wrong");
38                 }
39
40                 /// <summary>
41                 /// Contract.Result() has no effect, and always returns the default value for the type.
42                 /// </summary>
43                 [Test, RunAgainstReference]
44                 public void TestResult ()
45                 {
46                         int i = Contract.Result<int> ();
47                         object o = Contract.Result<object> ();
48
49                         Assert.AreEqual (0, i, "TestResult() int value wrong");
50                         Assert.IsNull (o, "TestResult() object value wrong");
51                 }
52
53                 /// <summary>
54                 /// Contract.ValueAtReturn() has no effect, and always returns the default value for the type.
55                 /// </summary>
56                 [Test, RunAgainstReference]
57                 public void TestValueAtReturn ()
58                 {
59                         int iOut, i;
60                         object oOut, o;
61
62                         i = Contract.ValueAtReturn (out iOut);
63                         o = Contract.ValueAtReturn (out oOut);
64
65                         Assert.AreEqual (0, i, "TestValueAtReturn() int return value wrong");
66                         Assert.IsNull (o, "TestValueAtReturn() object return value wrong");
67                         Assert.AreEqual (0, iOut, "TestValueAtReturn() int out value wrong");
68                         Assert.IsNull (oOut, "TestValueAtReturn() object out value wrong");
69                 }
70
71         }
72
73 }
74