1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
// ****************************************************************
// Copyright 2007, Charlie Poole
// This is free software licensed under the NUnit license. You may
// obtain a copy of the license at http://nunit.org.
// ****************************************************************
using System;
namespace NUnit.Framework.Constraints
{
[TestFixture]
public class SubstringTest : ConstraintTestBase, IExpectException
{
[SetUp]
public void SetUp()
{
theConstraint = new SubstringConstraint("hello");
expectedDescription = "String containing \"hello\"";
stringRepresentation = "<substring \"hello\">";
}
internal object[] SuccessData = new object[] { "hello", "hello there", "I said hello", "say hello to fred" };
internal object[] FailureData = new object[] { "goodbye", "HELLO", "What the hell?", string.Empty, null };
internal string[] ActualValues = new string[] { "\"goodbye\"", "\"HELLO\"", "\"What the hell?\"", "<string.Empty>", "null" };
public void HandleException(Exception ex)
{
Assert.That(ex.Message, new EqualConstraint(
TextMessageWriter.Pfx_Expected + "String containing \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...\"" + Environment.NewLine +
TextMessageWriter.Pfx_Actual + "\"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...\"" + Environment.NewLine));
}
}
[TestFixture]
public class SubstringTestIgnoringCase : ConstraintTestBase
{
[SetUp]
public void SetUp()
{
theConstraint = new SubstringConstraint("hello").IgnoreCase;
expectedDescription = "String containing \"hello\", ignoring case";
stringRepresentation = "<substring \"hello\">";
}
internal object[] SuccessData = new object[] { "Hello", "HellO there", "I said HELLO", "say hello to fred" };
internal object[] FailureData = new object[] { "goodbye", "What the hell?", string.Empty, null };
internal string[] ActualValues = new string[] { "\"goodbye\"", "\"What the hell?\"", "<string.Empty>", "null" };
}
//[TestFixture]
//public class EqualIgnoringCaseTest : ConstraintTest
//{
// [SetUp]
// public void SetUp()
// {
// Matcher = new EqualConstraint("Hello World!").IgnoreCase;
// Description = "\"Hello World!\", ignoring case";
// }
// object[] SuccessData = new object[] { "hello world!", "Hello World!", "HELLO world!" };
// object[] FailureData = new object[] { "goodbye", "Hello Friends!", string.Empty, null };
// string[] ActualValues = new string[] { "\"goodbye\"", "\"Hello Friends!\"", "<string.Empty>", "null" };
//}
}
|