Search Results for

    Show / Hide Table of Contents

    Class SubstringConstraint

    SubstringConstraint can test whether a string contains the expected substring.

    Inheritance
    object
    Constraint
    StringConstraint
    SubstringConstraint
    Implements
    IConstraint
    IResolveConstraint
    Inherited Members
    StringConstraint.expected
    StringConstraint.caseInsensitive
    StringConstraint.descriptionText
    StringConstraint.ApplyTo<TActual>(TActual)
    StringConstraint.Description
    Constraint.ApplyTo<TActual>(ActualValueDelegate<TActual>)
    Constraint.ApplyTo<TActual>(ref TActual)
    Constraint.ApplyToAsync<TActual>(Func<Task<TActual>>)
    Constraint.GetTestObject<TActual>(ActualValueDelegate<TActual>)
    Constraint.ToString()
    Constraint.GetStringRepresentation(IEnumerable)
    Constraint.GetStringRepresentation()
    Constraint.After(int)
    Constraint.After(int, int)
    Constraint.DisplayName
    Constraint.Arguments
    Constraint.Builder
    Constraint.And
    Constraint.With
    Constraint.Or
    object.GetType()
    object.MemberwiseClone()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: NUnit.Framework.Constraints
    Assembly: nunit.framework.dll
    Syntax
    public class SubstringConstraint : StringConstraint, IConstraint, IResolveConstraint

    Constructors

    View Source

    SubstringConstraint(string)

    Initializes a new instance of the SubstringConstraint class.

    Declaration
    public SubstringConstraint(string expected)
    Parameters
    Type Name Description
    string expected

    The expected.

    Properties

    View Source

    IgnoreCase

    Modify the constraint to ignore case in matching. This will call Using(StringComparison.CurrentCultureIgnoreCase).

    Declaration
    public override StringConstraint IgnoreCase { get; }
    Property Value
    Type Description
    StringConstraint
    Overrides
    StringConstraint.IgnoreCase
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when a comparison type different than CurrentCultureIgnoreCase was already set.

    Methods

    View Source

    Matches(string?)

    Test whether the constraint is satisfied by a given value

    Declaration
    protected override bool Matches(string? actual)
    Parameters
    Type Name Description
    string actual

    The value to be tested

    Returns
    Type Description
    bool

    True for success, false for failure

    Overrides
    StringConstraint.Matches(string?)
    View Source

    Using(StringComparison)

    Modify the constraint to the specified comparison.

    Declaration
    public SubstringConstraint Using(StringComparison comparisonType)
    Parameters
    Type Name Description
    StringComparison comparisonType
    Returns
    Type Description
    SubstringConstraint
    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when a comparison type different than comparisonType was already set.

    Implements

    IConstraint
    IResolveConstraint
    • View Source
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0