public void SetUp() { Matcher = new SubstringConstraint("hello"); GoodValues = new object[] { "hello", "hello there", "I said hello", "say hello to fred" }; BadValues = new object[] { "goodbye", "What the hell?", string.Empty, null }; Description = "String containing \"hello\""; }
public void SetUp() { Matcher = new SubstringConstraint("hello").IgnoreCase; GoodValues = new object[] { "Hello", "HellO there", "I said HELLO", "say hello to fred" }; BadValues = new object[] { "goodbye", "What the hell?", string.Empty, null }; Description = "String containing \"hello\", ignoring case"; }
protected override void SetUp() { Matcher = new SubstringConstraint("hello").IgnoreCase; GoodValues = new object[] { "Hello", "HellO there", "I said HELLO", "say hello to fred" }; BadValues = new object[] { "goodbye", "What the hell?", string.Empty, null }; Description = "\"hello\""; }
internal static void ShouldContain(this string actualValue, string expectedValue, string errorMessage = null) { //Regular StringAssert.Contains uses CurrentCulture, and fails in .NET 5.0 var constraint = new SubstringConstraint(expectedValue).Using(StringComparison.Ordinal); Assert.That(actualValue, constraint, errorMessage); }
/// <summary> /// Test whether the constraint is satisfied by a given value /// </summary> /// <param name="actual">The value to be tested</param> /// <returns>True for success, false for failure</returns> public override ConstraintResult ApplyTo <TActual>(TActual actual) { if (actual is string) { StringConstraint constraint = new SubstringConstraint((string)_expected); if (_ignoreCase) { constraint = constraint.IgnoreCase; } _realConstraint = constraint; } else { _realConstraint = new CollectionContainsConstraint(_expected); } return(_realConstraint.ApplyTo(actual)); }
/// <summary> /// Test whether the constraint is satisfied by a given value /// </summary> /// <param name="actual">The value to be tested</param> /// <returns>True for success, false for failure</returns> public override ConstraintResult ApplyTo <TActual>(TActual actual) { if (actual is string) { StringConstraint constraint = new SubstringConstraint((string)_expected); if (_ignoreCase) { constraint = constraint.IgnoreCase; } _realConstraint = constraint; } else { var itemConstraint = new EqualConstraint(_expected); if (_ignoreCase) { itemConstraint = itemConstraint.IgnoreCase; } _realConstraint = new SomeItemsConstraint(itemConstraint); } return(_realConstraint.ApplyTo(actual)); }
/// <summary> /// Test whether the constraint is satisfied by a given value /// </summary> /// <param name="actual">The value to be tested</param> /// <returns>True for success, false for failure</returns> protected override ConstraintResult ApplyConstraint <TActual>(TActual actual) { if (actual is string && ExpectedValue is string) { StringConstraint constraint = new SubstringConstraint(ExpectedValue as string); if (_ignoreCase) { constraint = constraint.IgnoreCase; } _realConstraint = constraint; } else { var itemConstraint = new EqualConstraint <TExpected>(ExpectedValue); if (_ignoreCase) { itemConstraint = itemConstraint.IgnoreCase; } _realConstraint = new SomeItemsConstraint(itemConstraint); } return(_realConstraint.ApplyTo(actual)); }
public void SetUp() { theConstraint = new SubstringConstraint("hello").IgnoreCase; expectedDescription = "String containing \"hello\", ignoring case"; stringRepresentation = "<substring \"hello\">"; }
public void SetUp() { Matcher = new SubstringConstraint("hello").IgnoreCase; GoodValues = new object[] { "Hello", "HellO there", "I said HELLO", "say hello to fred" }; BadValues = new object[] { "goodbye", "What the hell?", string.Empty, null }; Description = "String containing \"hello\", ignoring case"; }
public void SetUp() { Matcher = new SubstringConstraint("hello"); GoodValues = new object[] { "hello", "hello there", "I said hello", "say hello to fred" }; BadValues = new object[] { "goodbye", "What the hell?", string.Empty, null }; Description = "String containing \"hello\""; }
public void SetUp() { theConstraint = new SubstringConstraint("hello").IgnoreCase; expectedDescription = "String containing \"hello\", ignoring case"; stringRepresentation = "<substring \"hello\">"; }