Yes, that does indeed say “RC 10.”  The 10th iteration of 4.3.0 is now available as a pre-release package on NuGet.  Read on to see what’s changed with partial matching in this go-round!

image

[more]

The big features in 4.3.0 all deal with strongly-typed partial matching.  The previous version added support for doing strongly-typed Looks.Like, and it also added support for using Moq’s matchers with the partial versions of both ShouldLookLike and Looks.Like. 

As I mentioned at the end of that post, using Moq’s matchers was risky.  I had to hook in to private and internal functionality.  Instead of waiting for that bomb to go off, I decided to go a different route for 4.3.0, which you can see starting with this preview release.

Instead of using Moq’s matchers like It.IsAny<T> and It.Is<T>, you can now use SpecsFor’s Any.OfValue Any.ValueOf and Some.ValueOf methods (as well as some other helpers!)  Here’s what it looks like now:

[Test]
public void then_it_verifies_correctly_if_the_matcher_is_satisfied()
{
    GetMockFor<ITrainYard>().Object
        .RetrieveLuggage(new LuggageTicket
        {
            IssuedTo = "Jane Doe",
            Issued = DateTime.Now,
        });

    GetMockFor<ITrainYard>()
        .Verify(x => x.RetrieveLuggage(Looks.Like(() => new LuggageTicket
        {
            IssuedTo = "Jane Doe",
            Issued = Some.ValueOf<DateTime>(d => DateTime.Now.Subtract(d) < TimeSpan.FromSeconds(1))
        })));
}

Not only is this a safer path going forward, but it also allowed me to handle some edge cases that Moq’s matchers didn’t, such as matches between nullable and non-nullable types.

This is a breaking change from RC09.  Any code you have that was using Moq’s matchers will need to be updated.  Sorry about that. 

Assuming there are no issues found with this release, I plan to ship the final version of 4.3.0 Really Soon.  Let me know how much you hate me in the comments.