tpierrain/NFluent

Add casting support to improve some checks.

Closed this issue · 1 comments

When one needs to use IsInstanceOf to check that the sut is of a specific type (e.g. string instead of object), one needs to cast explicitely the sut afterward to refine the check.
E.g:

Expected Syntax

It would be simpler and clearer to write:

object basic = "abcd";
Check.That(basic).IsInstanceOf<string>().Which().IsEqualIgnoringCase("ABCD");

Current syntax

Instead of:

object basic = "abcd";
Check.That(basic).IsInstanceOf<string>();
Check.That((string) basic).IsEqualIgnoringCase("ABCD");

Possible Solution

Add support of Which keyword to that effect.

Implemented: added support of Which keyword to IsInstanceOf. Note that this feature is not available to the non generic version (**IsInstanceOfType(Type type)*) as type is not available at compile time (but at runtime).