The new version of SpecsFor should now be live on NuGet. This version uses the latest version of StructureMap and Moq and fixes a couple of other issues.
SpecsFor also gained a new partial matching method a while back, I just haven’t had time blog about it. Read on to find out how to use it.
[more]
Partial matching is pretty awesome:
[Test] public void then_returns_the_expected_model() { _account.ShouldLookLike(() => new Customer { //AccountNumber = ? //Ignore! CustomerName = "Atticus Finch", Balance = 5042.61 }); }
Partial matching with fuzzy checks is even better:
[Test] public void then_you_can_check_for_values_in_a_range() { var engine = new Engine {YearBuilt = 2015}; engine.ShouldLookLike(() => new Engine { YearBuilt = Some.ValueInRange(2014, 2016) }); }
Partial matching with fuzzy checks against items within a collection is just awesome:
[Test] public void then_you_can_check_for_an_item_in_a_list() { var warehouse = new Warehouse { Engines = new[] {new Engine {YearBuilt = 2013}, new Engine {YearBuilt = 2016}} }; warehouse.ShouldLookLike(() => new Warehouse { Engines = Some.ListContaining(() => new Engine { //Yep, you can use partial matching recursively! YearBuilt = Some.ValueOf<int>(i => i % 2 == 0) }) }); }
Enjoy, and as always, please let me know if you run into any problems.