Assert.AreAllOfType 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
AreAllOfType(Type, IEnumerable, String, String, String)
測試指定集合中的所有元素是否都是預期型別的實例(或由其衍生),若預期型別不在一個或多個元素的繼承階層中,或任何元素為空,則拋出例外。
public static void AreAllOfType(Type? expectedType, System.Collections.IEnumerable? collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * System.Collections.IEnumerable * string * string * string -> unit
Public Shared Sub AreAllOfType (expectedType As Type, collection As IEnumerable, Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")
參數
- expectedType
- Type
每個元素 collection的期望型態。
- collection
- IEnumerable
包含測試預期屬於指定類型元素的集合。
- message
- String
當 中的 collection 元素為空或不是 的 expectedType實例時,應包含在例外中包含的訊息。 該訊息會顯示在測試結果中。
- expectedTypeExpression
- String
預期型的語法表達式由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
例外狀況
若 expectedType 或 collection 為空,或 的 collection 某些元素為空或未繼承/實作 expectedType,則拋出 。
適用於
AreAllOfType<TExpected,TItem>(ReadOnlyMemory<TItem>, String, String)
測試指定記憶體中的所有元素是否都是 的實例(或源自) TExpected。
public static void AreAllOfType<TExpected,TItem>(ReadOnlyMemory<TItem> collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : ReadOnlyMemory<'Item> * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected, TItem) (collection As ReadOnlyMemory(Of TItem), Optional message As String = "", Optional collectionExpression As String = "")
類型參數
- TExpected
每個元素 collection 預期的類型。
- TItem
記憶體的元素類型。
參數
- collection
- ReadOnlyMemory<TItem>
測試預期包含元素的記憶體應屬於指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TExpected,TItem>(Span<TItem>, String, String)
測試指定區間內的所有元素是否都是 的實例(或衍生自) TExpected。
public static void AreAllOfType<TExpected,TItem>(Span<TItem> collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : Span<'Item> * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected, TItem) (collection As Span(Of TItem), Optional message As String = "", Optional collectionExpression As String = "")
類型參數
- TExpected
每個元素 collection 預期的類型。
- TItem
跨度的元素類型。
參數
- collection
- Span<TItem>
包含元素的張成預期為指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TExpected,TItem>(ReadOnlySpan<TItem>, String, String)
測試指定區間內的所有元素是否都是 的實例(或衍生自) TExpected。
public static void AreAllOfType<TExpected,TItem>(ReadOnlySpan<TItem> collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : ReadOnlySpan<'Item> * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected, TItem) (collection As ReadOnlySpan(Of TItem), Optional message As String = "", Optional collectionExpression As String = "")
類型參數
- TExpected
每個元素 collection 預期的類型。
- TItem
跨度的元素類型。
參數
- collection
- ReadOnlySpan<TItem>
包含元素的張成預期為指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TExpected,TItem>(Memory<TItem>, String, String)
測試指定記憶體中的所有元素是否都是 的實例(或源自) TExpected。
public static void AreAllOfType<TExpected,TItem>(Memory<TItem> collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : Memory<'Item> * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected, TItem) (collection As Memory(Of TItem), Optional message As String = "", Optional collectionExpression As String = "")
類型參數
- TExpected
每個元素 collection 預期的類型。
- TItem
記憶體的元素類型。
參數
- collection
- Memory<TItem>
測試預期包含元素的記憶體應屬於指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TExpected>(IEnumerable, String, String)
測試指定集合中的所有元素是否都是預期型別的實例(或由其衍生),若預期型別不在一個或多個元素的繼承階層中,或任何元素為空,則拋出例外。
public static void AreAllOfType<TExpected>(System.Collections.IEnumerable? collection, string? message = "", string collectionExpression = "");
static member AreAllOfType : System.Collections.IEnumerable * string * string -> unit
Public Shared Sub AreAllOfType(Of TExpected) (collection As IEnumerable, Optional message As String = "", Optional collectionExpression As String = "")
類型參數
- TExpected
每個元素 collection 預期的類型。
參數
- collection
- IEnumerable
包含測試預期屬於指定類型元素的集合。
- message
- String
當 中的 collection 元素為空或不是 的 TExpected實例時,應包含在例外中包含的訊息。 該訊息會顯示在測試結果中。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
例外狀況
若 collection 為空,或某些 collection 元素為空,或未繼承/實作 TExpected,則拋出 。
適用於
AreAllOfType<TItem>(Type, ReadOnlyMemory<TItem>, String, String, String)
測試指定記憶體中的所有元素是否都是預期型別的實例(或衍生自)。
public static void AreAllOfType<TItem>(Type? expectedType, ReadOnlyMemory<TItem> collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * ReadOnlyMemory<'Item> * string * string * string -> unit
Public Shared Sub AreAllOfType(Of TItem) (expectedType As Type, collection As ReadOnlyMemory(Of TItem), Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")
類型參數
- TItem
記憶體的元素類型。
參數
- expectedType
- Type
每個元素 collection的期望型態。
- collection
- ReadOnlyMemory<TItem>
測試預期包含元素的記憶體應屬於指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- expectedTypeExpression
- String
預期型的語法表達式由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TItem>(Type, ReadOnlySpan<TItem>, String, String, String)
測試指定區間內的所有元素是否都是預期型態的實例(或衍生自)。
public static void AreAllOfType<TItem>(Type? expectedType, ReadOnlySpan<TItem> collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * ReadOnlySpan<'Item> * string * string * string -> unit
Public Shared Sub AreAllOfType(Of TItem) (expectedType As Type, collection As ReadOnlySpan(Of TItem), Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")
類型參數
- TItem
跨度的元素類型。
參數
- expectedType
- Type
每個元素 collection的期望型態。
- collection
- ReadOnlySpan<TItem>
包含元素的張成預期為指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- expectedTypeExpression
- String
預期型的語法表達式由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TItem>(Type, Memory<TItem>, String, String, String)
測試指定記憶體中的所有元素是否都是預期型別的實例(或衍生自)。
public static void AreAllOfType<TItem>(Type? expectedType, Memory<TItem> collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * Memory<'Item> * string * string * string -> unit
Public Shared Sub AreAllOfType(Of TItem) (expectedType As Type, collection As Memory(Of TItem), Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")
類型參數
- TItem
記憶體的元素類型。
參數
- expectedType
- Type
每個元素 collection的期望型態。
- collection
- Memory<TItem>
測試預期包含元素的記憶體應屬於指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- expectedTypeExpression
- String
預期型的語法表達式由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。
適用於
AreAllOfType<TItem>(Type, Span<TItem>, String, String, String)
測試指定區間內的所有元素是否都是預期型態的實例(或衍生自)。
public static void AreAllOfType<TItem>(Type? expectedType, Span<TItem> collection, string? message = "", string expectedTypeExpression = "", string collectionExpression = "");
static member AreAllOfType : Type * Span<'Item> * string * string * string -> unit
Public Shared Sub AreAllOfType(Of TItem) (expectedType As Type, collection As Span(Of TItem), Optional message As String = "", Optional expectedTypeExpression As String = "", Optional collectionExpression As String = "")
類型參數
- TItem
跨度的元素類型。
參數
- expectedType
- Type
每個元素 collection的期望型態。
- collection
- Span<TItem>
包含元素的張成預期為指定類型。
- message
- String
當斷言失敗時,例外中應包含訊息。
- expectedTypeExpression
- String
預期型的語法表達式由編譯器透過呼叫者參數表達式給出。 使用者不應該傳遞這個參數的值。
- collectionExpression
- String
由編譯器透過呼叫者參數表達式所提供的收集語法表達式。 使用者不應該傳遞這個參數的值。