Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01: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