共用方式為


StringAssert.Matches 方法 (String, Regex)

確認指定的字串符合規則運算式。

命名空間:  Microsoft.VisualStudio.TestTools.UnitTesting
組件:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

語法

'宣告
Public Shared Sub Matches ( _
    value As String, _
    pattern As Regex _
)
public static void Matches(
    string value,
    Regex pattern
)
public:
static void Matches(
    String^ value, 
    Regex^ pattern
)
static member Matches : 
        value:string * 
        pattern:Regex -> unit 
public static function Matches(
    value : String, 
    pattern : Regex
)

參數

  • value
    型別:System.String
    預期會符合 pattern 的字串。

例外狀況

例外狀況 條件
AssertFailedException

value 不符合 pattern。

備註

如果這個字串不符合運算式,判斷提示就會失敗。

.NET Framework 安全性

請參閱

參考

StringAssert 類別

Matches 多載

Microsoft.VisualStudio.TestTools.UnitTesting 命名空間