私は2つの拡張方法を持っています:
public static IPropertyAssertions<T> ShouldHave<T>(this T subject)
{
return new PropertyAssertions<T>(subject);
}
public static IPropertyAssertions<T> ShouldHave<T>(this IEnumerable<T> subject)
{
return new CollectionPropertyAssertions<T>(subject);
}
今、私はそれを使用するいくつかのコードを書きます:
List<Customer> collection2 = new List<Customer>();
collection2.ShouldHave(); //first overload is chosen
IEnumerable<Customer> collection3 = new List<Customer>();
collection3.ShouldHave(); //second overload is chosen
IEnumerable 型を明示的に指定した場合にのみ、2 番目のオーバーロードが選択されます。両方のケースで 2 番目のオーバーロードを選択する方法はありますか?