Esempio n. 1
0
 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\"";
 }
Esempio n. 2
0
 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";
 }
Esempio n. 3
0
 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);
        }
Esempio n. 5
0
        /// <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));
        }
Esempio n. 6
0
        /// <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));
        }
Esempio n. 7
0
        /// <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\">";
 }
Esempio n. 9
0
 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";
 }
Esempio n. 10
0
 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\"";
 }
Esempio n. 11
0
 public void SetUp()
 {
     theConstraint = new SubstringConstraint("hello").IgnoreCase;
     expectedDescription = "String containing \"hello\", ignoring case";
     stringRepresentation = "<substring \"hello\">";
 }