Moq v4.8.0-rc1 Release Notes

Release Date: 2017-12-08 // over 6 years ago
  • ๐Ÿš€ This is a pre-release version.

    โž• Added

    • ๐Ÿ‘Œ Support for sequential setup of void methods (@alexbestul, #463)
    • ๐Ÿ‘Œ Support for sequential setups (SetupSequence) of protected members (@stakx, #493)
    • ๐Ÿ‘Œ Support for callbacks for methods having ref or out parameters via two new overloads of Callback and Returns (@stakx, #468)
    • ๐Ÿ‘Œ Improved support for setting up and verifying protected members (including generic methods and methods having by-ref parameters) via the new duck-typing mock.Protected().As<TAnalog>() interface (@stakx, #495, #501)
    • ๐Ÿ‘Œ Support for ValueTask<TResult> when using the ReturnsAsync extension methods, similar to Task<TResult> (@AdamDotNet, #506)
    • 0๏ธโƒฃ Special handling for ValueTask<TResult> with DefaultValue.Empty (@stakx, #529)
    • ๐Ÿ‘Œ Support for custom default value generation strategies besides DefaultValue.Empty and DefaultValue.Mock: Implement custom providers by subclassing either DefaultValueProvider or LookupOrFallbackDefaultValueProvider, install them by setting Mock[Repository].DefaultValueProvider (@stakx, #533, #536)
    • ๐Ÿ‘ Allow DefaultValue.Mock to mock Task<TMockable> and ValueTask<TMockable> (@stakx, #502)
    • Match any value for ref parameters with It.Ref<T>.IsAny (or ItExpr.Ref<T>.IsAny for protected methods) as you would with It.IsAny<T>() for regular parameters (@stakx, #537)
    • ๐Ÿคก Mock.VerifyNoOtherCalls() to check whether all expected invocations have been verified -- can be used as an alternative to MockBehavior.Strict (@stakx, #539)

    ๐Ÿ”„ Changed

    • ๐Ÿ’ฅ Breaking change: SetupSequence now overrides pre-existing setups like all other Setup methods do. This means that exhausted sequences no longer fall back to previous setups to produce a "default" action or return value. (@stakx, #476)
    • Delegates passed to Returns are validated a little more strictly than before (return type and parameter count must match with method being set up) (@stakx, #520)
    • ๐Ÿ”„ Change assembly versioning scheme to major.minor.0.0 to help prevent assembly version conflicts and to reduce the need for binding redirects (@stakx, #554)

    ๐Ÿ›  Fixed

    • โšก๏ธ Update a method's invocation count correctly, even when it is set up to throw an exception (@stakx, #473)
    • Sequences set up with SetupSequence are now thread-safe (@stakx, #476)
    • ๐Ÿšš Record calls to methods that are named like event accessors (add_X, remove_X) so they can be verified (@stakx, #488)
    • ๐Ÿ‘Œ Improve recognition logic for sealed methods so that Setup throws when an attempt is made to set one up (@stakx, #497)
    • Let SetupAllProperties skip inaccessible methods (@stakx, #499)
    • ๐Ÿคก Prevent Moq from relying on a mock's implementation of IEnumerable<T> (@stakx, #510)
    • ๐Ÿšš Verification leaked internal MockVerificationException type; remove it (@stakx, #511)
    • ๐Ÿ–จ Custom matcher properties not printed correctly in error messages (@stakx, #517)
    • ๐Ÿคก Infinite loop when invoking delegate in Mock.Of setup expression (@stakx, #528)

    Obsoleted

    • ๐Ÿ—„ [Matcher] has been deprecated in favor of Match.Create (@stakx, #514)