Files
mono/mcs/class/corlib/Test/System.Diagnostics.Contracts/ContractAssumeTest.cs
T
Atsushi Eno 7aeb07d12f 2010-07-23 Atsushi Enomoto <[email protected]>
* ContractAssertTest.cs
	  ContractAssumeTest.cs
	  ContractHelperTest.cs
	  ContractMustUseRewriterTest.cs:
	  Mark couple of runtime breaking tests (on .NET 4.0) as [Ignore].
2010-07-23 16:00:51 +09:00

49 lines
1.2 KiB
C#
Executable File

#if NET_4_0
#define CONTRACTS_FULL
#define DEBUG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using System.Diagnostics.Contracts;
using MonoTests.System.Diagnostics.Contracts.Helpers;
namespace MonoTests.System.Diagnostics.Contracts {
[TestFixture]
public class ContractAssumeTest : TestContractBase {
/// <summary>
/// At runtime Contract.Assume() acts just like a Contract.Assert(), except the exact message in the assert
/// or exception is slightly different.
/// </summary>
[Test]
[Ignore ("This causes NUnit crash on .NET 4.0")]
public void TestAssumeMessage ()
{
try {
Contract.Assume (false);
Assert.Fail ("TestAssumeMessage() exception not thrown #1");
} catch (Exception ex) {
Assert.IsInstanceOfType (typeof(NotImplementedException), ex, "TestAssumeMessage() wrong exception type #1");
}
try {
Contract.Assume (false, "Message");
Assert.Fail ("TestAssumeMessage() exception not thrown #1");
} catch (Exception ex) {
Assert.IsInstanceOfType (typeof(NotImplementedException), ex, "TestAssumeMessage() wrong exception type #1");
}
}
// Identical to Contract.Assert, so no more testing required.
}
}
#endif