moq

The most popular and friendly mocking framework for .NET

OTHER License

Stars
5.7K
Committers
131

Bot releases are hidden (Show)

moq - v4.20.70 Latest Release

Published by kzu 11 months ago

What's Changed

🔨 Other

New Contributors

Full Changelog: https://github.com/devlooped/moq/compare/v4.20.69...v4.20.70

moq - v4.20.69

Published by kzu about 1 year ago

Let's make it more memorable when Moq became "safe" again.

What's Changed

moq - v4.20.2

Published by kzu about 1 year ago

What's Changed

🐛 Fixed bugs

NOTE: in addition, there were potential privacy issues raised with regards to the SHA256 hashing of
user' email to check for sponsorship, so it won't be coming back until that's properly addressed

Full Changelog: https://github.com/moq/moq/compare/v4.20.1...v4.20.2

moq - v4.20.1

Published by kzu about 1 year ago

What's Changed

✨ Implemented enhancements

  • Add Sponsor button to package readme 💜

Full Changelog: https://github.com/moq/moq/compare/v4.20.0...v4.20.1

moq - v4.20.0

Published by kzu about 1 year ago

What's Changed

✨ Implemented enhancements

🔨 Other

New Contributors

Full Changelog: https://github.com/moq/moq/compare/v4.18.4...v4.20.0

moq - v4.20.0-rc

Published by kzu about 1 year ago

What's Changed

🔨 Other

Full Changelog: https://github.com/moq/moq/compare/v4.20.0-beta...v4.20.0-rc

moq - v4.20.0-beta

Published by kzu about 1 year ago

What's Changed

✨ Implemented enhancements

🔨 Other

New Contributors

Full Changelog: https://github.com/moq/moq/compare/v4.18.4...v4.20.0-beta

moq - v4.20.0-alpha

Published by kzu about 1 year ago

What's Changed

✨ Implemented enhancements

🔨 Other

New Contributors

Full Changelog: https://github.com/moq/moq/compare/v4.18.4...v4.20.0-alpha

moq - 4.8.0

Published by stakx almost 2 years ago

Same as 4.8.0 Release Candidate 1, plus some significant speed improvements.

Changed

  • SetupAllProperties now fully supports property type recursion / loops in the object graph, thanks to deferred property initialization (@stakx, #550)
moq - 4.8.0 Release Candidate 1

Published by stakx almost 2 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)
  • 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)
moq - 4.8.1

Published by stakx almost 2 years ago

Added

  • C# 7 tuple support for DefaultValue.Empty and DefaultValue.Mock (@stakx, #563)

Changed

  • Downgraded System.Threading.Tasks.Extensions and System.ValueTuple dependencies to versions 4.3.0 as suggested by @tothdavid in order to improve Moq compatibility with .NET 4.6.1 / help prevent MissingMethodException and similar (@stakx, #571)

Fixed

  • CallBase regression with explicitly implemented interface methods (@stakx, #558)
moq - 4.8.2

Published by stakx almost 2 years ago

Changed

  • Upgraded System.ValueTuple dependency to version 4.4.0 in order to reestablish Moq compatibility with .NET 4.7 (and later), which already include the ValueTuple types (@stakx, #591)

Fixed

  • Wrong parameters count for extension methods in Callback and Returns (@Caraul, #575)
  • CallBase regression with members of additional interfaces (@stakx, #583)
moq - 4.8.3

Published by stakx almost 2 years ago

Added

  • Add ISetupSequentialResult<TResult>.Returns method overload that support delegate for deferred results (@snrnats, #594)
  • Support for C# 7.2's in parameter modifier (@stakx, #624, #625)
  • Missing methods ReturnsAsync and ThrowsAsync for sequential setups of methods returning a ValueTask (@stakx, #626)

Changed

  • Breaking change: All ReturnsAsync and ThrowsAsync setup methods now consistently return a new Task on each invocation (@snrnats, #595)
  • Speed up Mock.Of<T>() by approx. one order of magnitude (@informatorius, #598)
  • Update package reference to Castle.Core (DynamicProxy) from version 4.2.1 to 4.3.0 (@stakx, #624)

Fixed

  • Usage of ReturnsExtensions.ThrowsAsync() can cause UnobservedTaskException (@snrnats, #595)
  • ReturnsAsync and ThrowsAsync with delay parameter starts timer at setup (@snrnats, #595)
  • Returns regression with null function callback (@Caraul, #602)
moq - 4.9.0

Published by stakx almost 2 years ago

Added

  • Add Mock.Invocations property to support inspection of invocations on a mock (@Tragedian, #560)

Changed

  • Update package reference to Castle.Core (DynamicProxy) from version 4.3.0 to 4.3.1 (@stakx, #635)
  • Floating point values are formatted with higher precision (satisfying round-tripping) in diagnostic messages (@stakx, #637)

Fixed

  • CallBase disregarded for some base methods from non-public interfaces (@stakx, #641)

Obsoleted

  • mock.ResetCalls() has been deprecated in favor of mock.Invocations.Clear() (@stakx, #633)
moq - 4.10.0

Published by stakx almost 2 years ago

Added

  • ExpressionCompiler: An extensibility point for setting up alternate LINQ expression tree compilation strategies (@stakx, #647)
  • setup.CallBase() for void methods (@stakx, #664)
  • VerifyNoOtherCalls for MockRepository (@BlythMeister, #682)

Changed

  • Make VerifyNoOtherCalls take into account previous calls to parameterless Verify() and VerifyAll() (@stakx, #659)
  • Breaking change: VerifyAll now succeeds after a call to SetupAllProperties even when not all property accessors were invoked (stakx, #684)

Fixed

  • More precise out parameter detection for mocking COM interfaces with [in,out] parameters (@koutinho, #645)
  • Prevent false 'Different number of parameters' error with Returns callback methods that have been compiled from Expressions (@stakx, #654)
  • Verify exception should report configured setups for delegate mocks (@stakx, #679)
  • Verify exception should include complete call expression for delegate mocks (@stakx, #680)
  • Bug report #556: "Recursive setup expression creates ghost setups that make VerifyAll fail" (@stakx, #684)
  • Bug report #191: "Upgrade from 4.2.1409.1722 to 4.2.1507.0118 changed VerifyAll behavior" (@stakx, #684)
moq - 4.10.1

Published by stakx almost 2 years ago

Fixed

  • NullReferenceException when using SetupSet on indexers with multiple parameters (@idigra, #694)
  • CallBase should not be allowed for delegate mocks (@tehmantra, #706)

Changed

  • Dropped the dependency on the System.ValueTuple NuGet package, at no functional cost (i.e. value tuples are still supported just fine) (@stakx, #721)
  • Updated failure messages to show richer class names (@powerdude, #727)
  • Upgraded System.Reflection.TypeExtensions and System.Threading.Tasks.Extensions dependencies to versions 4.5.1 (@stakx, #729)
moq - 4.11.0 Release Candidate 1

Published by stakx almost 2 years ago

This is a pre-release version.

It contains several minor breaking changes, and there have been extensive internal rewrites in order to fix some very long-standing bugs in relation to argument matchers in fluent setup expressions.

Changed

  • The library now targets .NET Standard 2.0 instead of .NET Standard 1.x. This has been decided based on the official cross-platform targeting guideline and the End of Life announcement for .NET Core 1.x (@stakx, #784, #785)

  • Method overload resolution may change for:

    • mock.Protected().Setup("VoidMethod", ...)
    • mock.Protected().Verify("VoidMethod", ...)
    • mock.Protected().Verify<TResult>("NonVoidMethod", ...)

    due to a new overload: If the first argument is a bool, make sure that argument gets interpreted as part of args, not as exactParameterMatch (see also Added section below). (@stakx & @Shereef, #751, #753)

  • mock.Verify[All] now performs a more thorough error aggregation. Error messages of inner/recursive mocks are included in the error message using indentation to show the relationship between mocks. (@stakx, #762)

  • mock.Verify no longer creates setups, nor will it override existing setups, as a side-effect of using a recursive expression. (@stakx, #765)

  • More accurate detection of argument matchers with SetupSet and VerifySet, especially when used in fluent setup expressions or with indexers (@stakx, #767)

  • mock.Verify(expression) error messages now contain a full listing of all invocations that occurred across all involved mocks. Setups are no longer listed, since they are completely irrelevant in the context of call verification. (@stakx, #779, #780)

  • Indexers used as arguments in setup expressions are now eagerly evaluated, like all other properties already are (except when they refer to matchers) (@stakx, #794)

  • Update package reference to Castle.Core (DynamicProxy) from version 4.3.1 to 4.4.0 (@stakx, #797)

Added

  • New method overloads:

    • mock.Protected().Setup("VoidMethod", exactParameterMatch, args)
    • mock.Protected().Verify("VoidMethod", times, exactParameterMatch, args)
    • mock.Protected().Verify<TResult>("NonVoidMethod", times, exactParameterMatch, args)

    having a bool exactParameterMatch parameter. Due to method overload resolution, it was easy to think this already existed when in fact it did not, leading to failing tests. (@Shereef & @stakx, #753, #751)

  • Ability in mock.Raise and setup.Raises to raise events on sub-objects (inner mocks) (@stakx, #772)

Removed

  • Pex interop (which has not been maintained for years). You might notice changes when using Visual Studio's IntelliTest feature. (@stakx, #786)

Fixed

  • Setting multiple indexed object's property directly via LINQ fails (@TylerBrinkley, #314)
  • InvalidOperationException when specifiying setup on mock with mock containing property of type Nullable<T> (@dav1dev, #725)
  • Verify gets confused between the same generic and non-generic signature (@lepijohnny, #749)
  • Setup gets included in Verify despite being "unreachable" (@stakx, #703)
  • Verify can create setups that cause subsequent VerifyAll to fail (@stakx & @lepijohnny, #699)
  • Incomplete stack trace when raising an event with mock.Raise throws (@MutatedTomato, #738)
  • Mock.Raise only raises events on root object (@hallipr, #166)
  • Mocking indexer captures It.IsAny() as the value, even if given in the indexer argument (@idigra, #696)
  • VerifySet fails on non-trivial property setup (@TimothyHayes, #430)
  • Use of SetupSet 'forgets' method setup (@TimothyHayes, #432)
  • Recursive mocks don't work with argument matching (@thalesmello, #142)
  • Recursive property setup overrides previous setups (@jamesfoster, #110)
  • Formatting of enumerable object for error message broke EF Core test case (@MichaelSagalovich, #741)
  • Verify[All] fails because of lazy (instead of eager) setup argument expression evaluation (@aeslinger, #711)
  • ArgumentOutOfRangeException when setup expression contains indexer access (@mosentok, #714)
  • Incorrect implementation of Times.Equals (@stakx, #805)
moq - 4.11.0 Release Candidate 2

Published by stakx almost 2 years ago

This is a pre-release version.

Changed

  • Debug symbols (Moq.pdb) have moved into a separate NuGet symbol package (as per the current official guideline). If you want the Visual Studio debugger to step into Moq's source code, disable Just My Code, enable SourceLink, and configure NuGet's symbol server. (@stakx, #789)

Fixed

  • Regression: Unhelpful exception message when setting up an indexer with SetupProperty (@stakx, #823)
moq - 4.11.0

Published by stakx almost 2 years ago

Same as 4.11.0 Release Candidate 2. See changelog entries for the two pre-release versions.

moq - 4.12.0

Published by stakx almost 2 years ago

Changed

  • Improved performance for Mock.Of<T> and mock.SetupAllProperties() as the latter now performs property setups just-in-time, instead of as an ahead-of-time batch operation. (@vanashimko, #826)
  • Setups with no .Returns(…) nor .CallBase() no longer return default(T) for loose mocks, but a value that is consistent with the mock's CallBase and DefaultValue[Provider] settings. (@stakx, #849)

Added

  • New method overload sequenceSetup.ReturnsAsync(Func<T>) (@stakx, #841)
  • LINQ to Mocks support for strict mocks, i.e. new method overloads for Mock.Of, Mocks.Of, mockRepository.Of, and mockRepository.OneOf that accept a MockBehavior parameter. (@stakx, #842)

Fixed

  • Adding Callback to a mock breaks async tests (@marcin-chwedczuk-meow, #702)
  • mock.SetupAllProperties() now setups write-only properties for strict mocks, so that accessing such properties will not throw anymore. (@vanashimko, #836)
  • Regression: mock.SetupAllProperties() and Mock.Of<T> fail due to inaccessible property accessors (@Mexe13, #845)
  • Regression: VerifyNoOtherCalls causes stack overflow when mock setup returns the mocked object (@bash, #846)
  • Capture.In() no longer captures arguments when other setup arguments do not match (@ocoanet, #844).
  • CaptureMatch no longer invokes the capture callback when other setup arguments do not match (@ocoanet, #844).
Badges
Extracted from project README
Version Downloads Sponsors Clarius Org Kirill Osenkov MFB Technologies, Inc. Stephen Shaw Torutek DRIVE.NET, Inc. Ashley Medway Keith Pickford Thomas Bolon Kori Francis Toni Wenzel Giorgi Dalakishvili Uno Platform Dan Siegel Reuben Swartz Jacob Foshee Eric Johnson Ix Technologies B.V. David JENNI Jonathan Oleg Kyrylchuk Charley Wu Jakob Tikjøb Andersen Seann Alexander Tino Hager Mark Seemann Ken Bonny Simon Cropp agileworks-eu sorahex Zheyu Shen Vezel ChilliCream 4OTC Vincent Limo Brooke Hamilton Sponsor this project