1
// ****************************************************************
2
// Copyright 2007, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org.
5
// ****************************************************************
9
namespace NUnit.Framework.Tests
12
/// MessageCheckingTest is an abstract base for tests
13
/// that check for an expected message in the exception
16
public abstract class MessageChecker : AssertionHelper, IExpectException
18
protected string expectedMessage;
19
protected MessageMatch matchType = MessageMatch.Exact;
24
expectedMessage = null;
27
public void HandleException( Exception ex )
29
if ( expectedMessage != null )
34
case MessageMatch.Exact:
35
Assert.AreEqual( expectedMessage, ex.Message );
37
case MessageMatch.Contains:
38
Assert.That(ex.Message, Is.StringContaining(expectedMessage));
40
case MessageMatch.StartsWith:
41
Assert.That(ex.Message, Is.StringStarting(expectedMessage));
43
case MessageMatch.Regex:
44
Assert.That(ex.Message, Is.StringMatching(expectedMessage));
1
// ****************************************************************
2
// Copyright 2007, Charlie Poole
3
// This is free software licensed under the NUnit license. You may
4
// obtain a copy of the license at http://nunit.org.
5
// ****************************************************************
9
namespace NUnit.Framework.Tests
12
/// MessageCheckingTest is an abstract base for tests
13
/// that check for an expected message in the exception
16
public abstract class MessageChecker : AssertionHelper, IExpectException
18
protected string expectedMessage;
19
protected MessageMatch matchType = MessageMatch.Exact;
24
expectedMessage = null;
27
public void HandleException( Exception ex )
29
if ( expectedMessage != null )
34
case MessageMatch.Exact:
35
Assert.AreEqual( expectedMessage, ex.Message );
37
case MessageMatch.Contains:
38
Assert.That(ex.Message, Is.StringContaining(expectedMessage));
40
case MessageMatch.StartsWith:
41
Assert.That(ex.Message, Is.StringStarting(expectedMessage));
43
case MessageMatch.Regex:
44
Assert.That(ex.Message, Is.StringMatching(expectedMessage));