StringAssert Class
Verifies true/false propositions associated with strings in unit tests.
Inheritance Hierarchy
System.Object
Microsoft.VisualStudio.TestTools.UnitTesting.StringAssert
Namespace: Microsoft.VisualStudio.TestTools.UnitTesting
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
Syntax
'Declaration
Public NotInheritable Class StringAssert
public static class StringAssert
public ref class StringAssert abstract sealed
[<AbstractClass>]
[<Sealed>]
type StringAssert = class end
public final class StringAssert
Methods
Name | Description | |
---|---|---|
Contains(String, String) | Verifies that the first string contains the second string. This method is case sensitive. | |
Contains(String, String, String) | Verifies that the first string contains the second string. Displays a message if the assertion fails. This method is case sensitive. | |
Contains(String, String, String, array<Object[]) | Verifies that the first string contains the second string. Displays a message if the assertion fails, and applies the specified formatting to it. This method is case sensitive. | |
DoesNotMatch(String, Regex) | Verifies that the specified string does not match the regular expression. | |
DoesNotMatch(String, Regex, String) | Verifies that the specified string does not match the regular expression. Displays a message if the assertion fails. | |
DoesNotMatch(String, Regex, String, array<Object[]) | Verifies that the specified string does not match the regular expression. Displays a message if the assertion fails, and applies the specified formatting to it. | |
EndsWith(String, String) | Verifies that the first string ends with the second string. This method is case sensitive. | |
EndsWith(String, String, String) | Verifies that the first string ends with the second string. Displays a message if the assertion fails. This method is case sensitive. | |
EndsWith(String, String, String, array<Object[]) | Verifies that the first string ends with the second string. Displays a message if the assertion fails, and applies the specified formatting to it. This method is case sensitive. | |
Matches(String, Regex) | Verifies that the specified string matches the regular expression. | |
Matches(String, Regex, String) | Verifies that the specified string matches the regular expression. Displays a message if the assertion fails. | |
Matches(String, Regex, String, array<Object[]) | Verifies that the specified string matches the regular expression. Displays a message if the assertion fails, and applies the specified formatting to it. | |
StartsWith(String, String) | Verifies that the first string begins with the second string. This method is case sensitive. | |
StartsWith(String, String, String) | Verifies that the first string begins with the second string. Displays a message if the assertion fails. This method is case sensitive. | |
StartsWith(String, String, String, array<Object[]) | Verifies that the first string begins with the second string. Displays a message if the assertion fails, and applies the specified formatting to it. This method is case sensitive. |
Top
Remarks
This class contains a set of static methods that evaluate a Boolean condition. If this condition evaluates to true, the assertion passes.
An assertion verifies an assumption of truth for compared conditions.
If the condition being verified is not true, the assertion fails.
Important
The StringAssert class throws an AssertFailedException to signal a failure. This exception should not be captured. This exception is handled by the unit test engine to indicate an assert failure.
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also
Reference
Microsoft.VisualStudio.TestTools.UnitTesting Namespace