Here is the best "solution" I came to. First, we split ShouldHave methods:
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); }
Then try to use them:
var collection1 = new List<Customer>(); //first overload is chosen List<Customer> collection2 = new List<Customer>(); //first overload is chosen IEnumerable<Customer> collection3 = new List<Customer>(); //second overload is chosen