I have two extension 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);
}
Now I write some code which uses it:
List<Customer> collection2 = new List<Customer>();
collection2.ShouldHave(); //first overload is chosen
IEnumerable<Customer> collection3 = new List<Customer>();
collection3.ShouldHave(); //second overload is chosen
Second overload is chosen only if I explicitly specify IEnumerable type. Is there any way to make second overload to be chosen in both cases?
In Fluent Assertion 2.0 I’ve finally managed to solve the above problems in a decent way. Read all about that here:
http://www.dennisdoomen.net/2012/09/asserting-object-graph-equivalence.html