Assert.StartsWith Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| StartsWith(String, String, StringComparison, String, String, String) |
Tests whether the specified string begins with the specified prefix and throws an exception if the test string does not start with the prefix. |
| StartsWith(String, String, String, String, String) |
Tests whether the specified string begins with the specified prefix and throws an exception if the test string does not start with the prefix. |
| StartsWith(String, String, String) |
Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring. |
| StartsWith(String, String, StringComparison, String) |
Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring. |
StartsWith(String, String, StringComparison, String, String, String)
- Source:
- Assert.StartsWith.cs
Tests whether the specified string begins with the specified prefix and throws an exception if the test string does not start with the prefix.
public static void StartsWith(string? expectedPrefix, string? value, StringComparison comparisonType, string? message = "", string expectedPrefixExpression = "", string valueExpression = "");
static member StartsWith : string * string * StringComparison * string * string * string -> unit
Public Shared Sub StartsWith (expectedPrefix As String, value As String, comparisonType As StringComparison, Optional message As String = "", Optional expectedPrefixExpression As String = "", Optional valueExpression As String = "")
Parameters
- expectedPrefix
- String
The string expected to be a prefix of value.
- value
- String
The string that is expected to begin with expectedPrefix.
- comparisonType
- StringComparison
The comparison method to compare strings comparisonType.
- message
- String
The message to include in the exception when value
does not begin with expectedPrefix. The message is
shown in test results.
- expectedPrefixExpression
- String
The syntactic expression of expectedPrefix as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
- valueExpression
- String
The syntactic expression of value as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Exceptions
value is null, or expectedPrefix is null,
or value does not start with expectedPrefix.
Applies to
StartsWith(String, String, String, String, String)
- Source:
- Assert.StartsWith.cs
Tests whether the specified string begins with the specified prefix and throws an exception if the test string does not start with the prefix.
public static void StartsWith(string? expectedPrefix, string? value, string? message = "", string expectedPrefixExpression = "", string valueExpression = "");
static member StartsWith : string * string * string * string * string -> unit
Public Shared Sub StartsWith (expectedPrefix As String, value As String, Optional message As String = "", Optional expectedPrefixExpression As String = "", Optional valueExpression As String = "")
Parameters
- expectedPrefix
- String
The string expected to be a prefix of value.
- value
- String
The string that is expected to begin with expectedPrefix.
- message
- String
The message to include in the exception when value
does not begin with expectedPrefix. The message is
shown in test results.
- expectedPrefixExpression
- String
The syntactic expression of expectedPrefix as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
- valueExpression
- String
The syntactic expression of value as given by the compiler via caller argument expression. Users shouldn't pass a value for this parameter.
Exceptions
value is null, or expectedPrefix is null,
or value does not start with expectedPrefix.
Applies to
StartsWith(String, String, String)
- Source:
- Assert.StartsWith.cs
- Source:
- Assert.StartsWith.cs
Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.
public static void StartsWith(string? substring, string? value, string message = "");
static member StartsWith : string * string * string -> unit
Public Shared Sub StartsWith (substring As String, value As String, Optional message As String = "")
Parameters
- substring
- String
The string expected to be a prefix of value.
- value
- String
The string that is expected to begin with substring.
- message
- String
The message to include in the exception when value
does not begin with substring. The message is
shown in test results.
Exceptions
value is null, or substring is null,
or value does not start with substring.
Applies to
StartsWith(String, String, StringComparison, String)
- Source:
- Assert.StartsWith.cs
- Source:
- Assert.StartsWith.cs
Tests whether the specified string begins with the specified substring and throws an exception if the test string does not start with the substring.
public static void StartsWith(string? substring, string? value, StringComparison comparisonType, string message = "");
static member StartsWith : string * string * StringComparison * string -> unit
Public Shared Sub StartsWith (substring As String, value As String, comparisonType As StringComparison, Optional message As String = "")
Parameters
- substring
- String
The string expected to be a prefix of value.
- value
- String
The string that is expected to begin with substring.
- comparisonType
- StringComparison
The comparison method to compare strings comparisonType.
- message
- String
The message to include in the exception when value
does not begin with substring. The message is
shown in test results.
Exceptions
value is null, or substring is null,
or value does not start with substring.