All notable changes to this project will be documented in this file.
The format is loosely based on Keep a Changelog.
- Add
Mock.Invocations
property to support inspection of invocations on a mock (@Tragedian, #560)
- 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)
CallBase
disregarded for some base methods from non-public interfaces (@stakx, #641)
mock.ResetCalls()
has been deprecated in favor ofmock.Invocations.Clear()
(@stakx, #633)
- 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
andThrowsAsync
for sequential setups of methods returning aValueTask
(@stakx, #626)
- Breaking change: All
ReturnsAsync
andThrowsAsync
setup methods now consistently return a newTask
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)
- Usage of
ReturnsExtensions.ThrowsAsync()
can causeUnobservedTaskException
(@snrnats, #595) ReturnsAsync
andThrowsAsync
with delay parameter starts timer at setup (@snrnats, #595)Returns
regression with null function callback (@Caraul, #602)
- Upgraded
System.ValueTuple
dependency to version 4.4.0 in order to reestablish Moq compatibility with .NET 4.7 (and later), which already include theValueTuple
types (@stakx, #591)
- Wrong parameters count for extension methods in
Callback
andReturns
(@Caraul, #575) CallBase
regression with members of additional interfaces (@stakx, #583)
- C# 7 tuple support for
DefaultValue.Empty
andDefaultValue.Mock
(@stakx, #563)
- Downgraded
System.Threading.Tasks.Extensions
andSystem.ValueTuple
dependencies to versions 4.3.0 as suggested by @tothdavid in order to improve Moq compatibility with .NET 4.6.1 / help preventMissingMethodException
and similar (@stakx, #571)
CallBase
regression with explicitly implemented interface methods (@stakx, #558)
Same as 4.8.0-rc1 (see below), plus some significant speed improvements.
SetupAllProperties
now fully supports property type recursion / loops in the object graph, thanks to deferred property initialization (@stakx, #550)
This is a pre-release version.
- 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
orout
parameters via two new overloads ofCallback
andReturns
(@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 theReturnsAsync
extension methods, similar toTask<TResult>
(@AdamDotNet, #506) - Special handling for
ValueTask<TResult>
withDefaultValue.Empty
(@stakx, #529) - Support for custom default value generation strategies besides
DefaultValue.Empty
andDefaultValue.Mock
: Implement custom providers by subclassing eitherDefaultValueProvider
orLookupOrFallbackDefaultValueProvider
, install them by settingMock[Repository].DefaultValueProvider
(@stakx, #533, #536) - Allow
DefaultValue.Mock
to mockTask<TMockable>
andValueTask<TMockable>
(@stakx, #502) - Match any value for
ref
parameters withIt.Ref<T>.IsAny
(orItExpr.Ref<T>.IsAny
for protected methods) as you would withIt.IsAny<T>()
for regular parameters (@stakx, #537) Mock.VerifyNoOtherCalls()
to check whether all expected invocations have been verified -- can be used as an alternative toMockBehavior.Strict
(@stakx, #539)
- Breaking change:
SetupSequence
now overrides pre-existing setups like all otherSetup
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)
- 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)
[Matcher]
has been deprecated in favor ofMatch.Create
(@stakx, #514)
- Moq no longer collects source file information for verification error messages by default. A current .NET Framework regression (microsoft/dotnet#529) makes this extremely costly, so this is now an opt-in feature; see
Switches.CollectSourceFileInfoForSetups
(@stakx, #515)
Mock.Switches
andMockRepository.Switches
, which allow opting in and out of certain features (@stakx, #515)
- Update package reference to
Castle.Core
(DynamicProxy) from version 4.2.0 to 4.2.1 due to a regression; see castleproject/Core#309 for details (@stakx, #482)
TypeLoadException
s ("Method does not have an implementation") caused by the regression above, see e.g. #469 (@stakx, #482)
- Update package reference to
Castle.Core
(DynamicProxy) from version 4.1.1 to 4.2.0, which uses a new assembly versioning scheme that should eventually reduce assembly version conflicts and the need for assembly binding redirects (@stakx, #459)
mock.Object
should always return the exact same proxy object, regardless of whether the mock has been cast to an interface via.As<T>()
or not (@stakx, #460)
- Make setups for inaccessible internal members fail fast by throwing an exception (@stakx, #455)
- The redundant type
ObsoleteMockException
has been removed (@stakx)
- Make
SetupAllProperties
work correctly for same-typed sibling properties (@stakx, #442) - Switch back from portable PDBs to classic PDBs for better compatibility of SourceLink with older .NET tools (@stakx, #443)
- Make strict mocks recognize that
.CallBase()
can set up a return value, too (@stakx, #450)
- Add
[NeutralResourcesLanguage]
to assembly info for portable library use (@benbillbob, #394) - Add portable, SourceLink-ed debugging symbols (PDB) to NuGet package, enabling end users to step into Moq's source code (@stakx, #417)
- Move all hardcoded message strings to
Resources.resx
(@stakx, #403) - Update package reference to
Castle.Core
(DynamicProxy) from version 4.1.0 to 4.1.1 (@stakx, #416) - Clean up and simplify the build process by merging separate .NET Framework and .NET Standard projects (@stakx, #417)
- Replace outdated
ReleaseNotes.md
with newCHANGELOG.md
(@stakx, #423)
- Fix member name typo in reflection code (@JohanLarsson, #389)
- Make
Interceptor
more thread-safe duringmock.Setup
(@stakx, #392) - Make abstract events defined in classes work even when
CallBase
is true by suppressingInvokeBase()
(@stakx, #395) - Allow setting up null return values using
Mock.Of
(@stakx, #396) - Allow
Mock<T>.Raise
to raise events on child mocks instead of raising no or the wrong event (@stakx, #397) - Improve specificity of
Setup
/Verify
exception messages for static members and extension methods (@stakx, #400) - Prevent internal interception on a mock from changing its
DefaultValue
property (@vladonemo, #411) - Prevent stack overflow in conditional setups (@stakx, #412)
- Fix
NullReferenceException
caused by internally relying on a mock'sIEnumerable
implementation (@stakx, #413) - Improve method match accuracy in
ExtractProxyCall
so that the order of setting up methods in an hierarchy of interfaces does not matter (@stakx, #415) - Improve mockability of C++/CLI interfaces having custom modifiers (
modopt
,modreq
) in their method signatures (@stakx, #416) - Make types implementing the same generic type more than two times mockable (@stakx, #416)
- Fix misreported
Times
in verification error messages (@stakx, #417)
- Ensure that
null
never matches anIt.IsRegex(…)
(@stakx, #385)
- Fix mocking of non-virtual methods via
mock.As<TInterface>()
which was broken by #381 (@stakx, #387)
- Fix formatting inconsistencies for array values in
MockException.Message
(@stakx, #380) - Fix major "class method vs. interface method" bug introduced by #119 / commit 162a543 (@stakx, #381)
- Fix mocking for redeclared interface properties (get-set but get-only in base type) (@stakx, #382)
- Fix incorrect Castle.Core package reference in NuGet package specification (@stakx, #379)
- Extend
EmptyDefaultValueProvider
so it understands multidimensional arrays (return empty multidimensional arrays instead ofnull
) (@stakx, #360) - Update package reference to
Castle.Core
(DynamicProxy) from version 4.0.0 to 4.1.0, updateSystem
andMicrosoft
packages from versions 4.0.1 to 4.3.0 (@stakx, #369) - Clean up and reduce usage of conditional compilation (
#if
) (@stakx, #378)
- Ensure default mock names are (more) unique (@stakx, #359)
- Make
It.IsAny
,It.IsNotNull
work for COM types (@stakx, #361) - Fix equality check bug in
ExpressionKey
which meant Moq would sometimes ignore exact argument order in setups (@kostadinmarinov, #135; @stakx, #363) - Ensure incorrect implementations of
ISerializable
are caught properly (@stakx, #370) - Make event accessor recognition logic more correct (don't just rely on
add_
orremove_
name prefixes) (@stakx, #376)
- Add new
setup.ReturnsAsync
andsetup.ThrowsAsync
overloads allowing you to specify a delay (@jochenz, #289)
- Migrate .NET Core project to the new
.csproj
format (@jeremymeng, #336)
- Add overload in
mock.Protected()
setups to enforce the old behavior of exact parameter matching (new behavior fails for specific overloads) (@80er, #347)
Minor change only (fix typo in documentation)
Minor change only (update project URL in NuGet package metadata)
Minor change only (add download badge to README.md
)
Minor change only (update license URL in NuGet package metadata)
- Allow setting up of protected methods with nullable parameters (@RobSiklos, #200)
- Fix incorrect code example in XML documentation comment for
Mock.Verify
(@jcockhren, #333) - Fix bug in
HasMatchingParameterTypes
which causedProtected().Verify
to reject valid mocks (@jeremymeng, #335)
Minor change only (fix typo in documentation)
Minor change only (correcting Moq version after semver violation) This version is the successor of 4.6.62-alpha.
This version is the predecessor of 4.7.0 and essentially a cleaned up merge of both 4.5.30 and 4.6.39-alpha.
Note: The release notes for some Moq versions 4.6.*-alpha are still missing. They need to be reconstructed from the commit history and the GitHub issue archive. If you would like to help make this changelog more complete, any pull requests towards that goal are appreciated!
- Fix issue in
ExpressionKey
that caused identical setups to no longer be considered the same (@MatKubicki, #313)
- Make the recently added
setup.ReturnsAsync(Func<TResult> result)
evaluate its argument lazily, likesetup.Returns
would (@SaroTasciyan, #309)
- New method
setup.ReturnsAsync(Func<TResult> result)
(@joeenzminger, @tlycken, #297)
- Improves comparison of call arguments in
ExpressionKey
so that setups for the same method but with differing arguments don't override each other (@MatKubicki, #291)
- Properly raise events when mocked type implements multiple interfaces (@bradreimer, #288)
- Fix
mock.Reset()
which so far forgot to also clear all existing calls in the interceptor (@anilkamath87, #277)
- Ensure that mocking of
System.Object
methods always works, even in strict mode (again) (@kolomanschaft, #280)
- Make
SetupAllProperties
work withDefaultValue.Mock
in the presence of object graph loops (i.e. when a type contains a property having the same type) (@vladonemo, #245) - Prevent invalid implementations of
ISerializable
from being mocked (as DynamicProxy cannot handle these) via the newSerializableTypesValueProvider
decorator (@vladonemo, #245)
- Ensure that mocking of
System.Object
methods always works, even in strict mode (@kolomanschaft, #279)
- Allow mocking of
System.Object
methods (ToString
,Equals
, andGetHashCode
) (@kolomanschaft, #250)
Verify
exception messages should include actual array values for specific calls instead of justT[]
or variable names (@hahn-kev, #264)
- Add helper classes
Capture
,CaptureMatch<T>
to simplify parameter capture (@ocoanet, #251)
Minor change only (remove download badge from README.md
)
Minor change only (add .editorconfig
file)
- Reference Castle.Core as a NuGet package dependency instead of ILMerge-ing it into Moq's own assembly. (@kzu)
- Update package reference to
GitInfo
from version 1.1.14 to 1.1.15 to fix versioning issue with cached Git info (@kzu)
- Remove debugging symbols (PDB) from package since GitLink doesn't seem to be working (@kzu)
- New helper methods
Mock.Verify(params Mock[] mocks)
andMock.VerifyAll(...)
(@RehanSaeed, #238)
Minor change only (update release notes in NuGet package metadata) This version is the successor of 4.5.9-alpha.
This version is the predecessor of 4.5.0.
- Fix broken hashing in
ExpressionKey
that causes Moq to not be able to distinguish method setups differing only in the exact argument order (@LeonidLevin, #262)
- Remove (for the time being) official statement in release notes that Moq supports .NET Core (@kzu)
- Add
ReturnsAsync
andThrowsAsync
methods for sequential values setups (@abatishchev, #261)
- Migrate to .NET 4.5 and NuGet 3 (@kzu)
- Update package reference to
GitInfo
from version 1.1.13 to 1.1.14 (@kzu)
- Remove COM unit tests (@kzu)
- Remove legacy Silverlight unit test project (@kzu)
- Remove
[NeutralResourcesLanguage]
attribute from main assembly (@kzu)
- Avoid race conditions / improve thread safety of
MockDefaultValueProvider
(@mizbrodin, #207) - Fix a code typo in
ExpressionComparer
(@AppChecker, #242) - When mocking delegates, copy parameter attributes so
out
parameters work correctly (@urasandesu, #255)
- Add Gitter badge to
README.md
(@kzu)
- Upgrade to Castle.Core version 3.3.3 (@MSK61, @kzu, #204)
- Make Task Parallel Library (TPL) code Silverlight 5 compatible (@iskiselev, #148)
- Fox license hyperlink so it points to correct version of the BSD license (@chkpnt, #198)
- Move Silverlight 5 assemblies in proper
lib\sl5
folder (instead oflib\sl4
) in the NuGet package (@kzu)
- Add new
mock.Reset()
extension method (@ashmind, #138)
- Allow
null
to match nullable value types (@pkpjpm, #185)
- Add NuGet badges to
README.md
(@kzu) - Add generic type argument information in exception messages for easier debugging (@hasaki, #177)
- Migrate Silverlight support from version 4 to 5 (@kzu)
- Upgrade source code to Visual Studio 2013 (@kzu)
- Fix
NullReferenceException
when passingnull
to a nullable argument but trying to match it with a non-nullableIsAny
(@benjamin-hodgson, #160) - Fix infinite loop when calling
SetupAllProperties
for entities with a hierarchy (@Moq, #180)
SetupAllProperties
doesn't setup properties that don't have a setter (@NGloreous, #137)- Fix DynamicProxy-related
NotImplementedException
when mocking interfaces withCallBase = true
(@rjasica, #145)
Minor change only (update NuGet metadata) This version was released twice under different version numbers.
- Migrate to MSBuild version 12 (@kzu)
- Enable
mock.As<TInterface>()
syntax for all implemented interfaces (except COM interfaces) even aftermock.Object
has been called (@scott-xu, #119, #123)
- Change
README.md
to show the use ofAtMostOnce
inVerify
phase instead ofSetup
phase (@kzu)
- Ordered call issue with invocations with same arguments in
MockSequence
(@drieseng, #97) - Update various hyperlinks in
README.md
(@kzu) - Improve Moq's support for curried delegates and fix failing unit tests when compiling Moq with Roslyn (@theoy, #125)
- Allow mocks to have names (@pimterry, #76, #83)
- Make
InterfaceProxy
class publicly visible to reenable mocking of interfaces (@pimterry, #99)
- Remove commercial licenses offer in
README.md
(@kzu)
- Improve thread safety by splitting the interceptor's context into global one and one for the current proxy invocation only (@MatKubicki, #80)
- Improve thread safety in
Interceptor
and fix multithreading tests (@MatKubicki, #68)
- Fix
NullReferenceException
when trying to get a default value forTask<T>
whenT
is a reference type (@alextercete, #73)
Minor change only (update release notes)
InSequence
setups can now be used on the same mock instance (@halllo, #72)
- Move extension methods in class
Moq.Language.Flow.IReturnsExtensions
toMoq.ReturnsExtensions
for better discoverability (@jdom, #71)
- Add
ReturnsAsync
andThrowsAsync
setup methods for better async support (@Blewzman, #60) - Migrate
README.md
content from Google Code (@kzu)
- Change
EmptyDefaultValueProvider
so it does not returnnull
forTask
andTask<T>
types, but completed, awaitable tasks (@alextercete, #66)
- Add
Throws
method to sequential value setups for testing retry logic in web services (@kellyselden, #59)
- Matchers should not ignore implicit type conversions (@svick, #56)
This version was released twice under different version numbers.
- Fix regression bug surrounding
Mock.As<TInterface>()
: Prevent early initialization of mock from checking for delegate mocks. (@kzu, #54)
- Allow resetting of all call counts (those that will be compared with
Times
) (@salfab, #55)
This version was released twice under different version numbers.
- New
It.IsNotNull<T>
matcher (@Pjanssen, #40) - Add covariant
IMock<out T>
interface toMock<T>
(@tkellogg, #44)
- Rename
Changelog.txt
toReleaseNotes.md
and inject the latter into the NuGet metadata (@Moq, #52)
- Fix "collection modified" exception thrown as result of more methods being called on a mock while verifying method calls (@yonahw, #36)
- Fix
NullReferenceException
when subscribing to an event (@bittailor, #39) - Fix thread safety issue (
IndexOutOfRangeException
) on setup (@stoo101, #51)
Minor change only (change title in NuGet package metadata)
- Add capability for mocking delegates (event handlers) (@quetzalcoatl, #4)
- Allow
CallBase
for specific method / property (@srudin, #8) - New matchers
It.IsIn
andIt.IsNotIn
(@rdingwall, #27) - Add
.gitignore
file (@yorah, #10 / @FellicePollano, #30) - Add new
Verify
method overload group that accepts aTimes
instance (@ChrisMissal, #34)
- Update Castle.Core assemblies from version 1.2.0.0 to 3.2.0, fetch Castle.Core via NuGet (@yorah, #11 / @kzu)
- Corrected Verify method behavior for generic methods calls (@Suremaker, #25)
- Split up
Interceptor.Intercept
into a set of 8 strategies, introduceInterceptionAction
(@FellicePollano, #31)
- Fix
SetupSequentialContext
to increment counter also afterThrows
(@lukas-ais, #7) - Make
Mock.Of
work on properties with non-public setters (@yorah, #9, #19) - Adding (and removing) handlers for events declared on interfaces when
CallBase = true
(@IharBury, #13) - Distinguish between verification exception and mock crash (@quetzalcoatl, #16)
- Improve thread safety of
Interceptor
class (@FelicePollano, #29)
Note: Release notes in the above format are not available for ealier versions of Moq. The above changelog entries have been reconstructed from the Git commit history. What follows below are the original release notes, for which maintenance stopped around Moq version 4.5. They are nevertheless included below as they go back further in time.
- Updated to .NET 4.5
- Dropped support for .NET < 4.5 and Silverlight
- Remove ILMerge. Depend on Castle NuGet package instead.
- Added support for Roslyn
- Automatically add implemented interfaces to mock
- Improved support for async APIs by making default value a completed task
- Added support for async Returns and Throws
- Improved mock invocation sequence testing
- Improved support for multi-threaded tests
- Added support for named mocks
- Added covariant
IMock<out T>
interface toMock<T>
- Added
It.IsNotNull<T>
- Fix: 'NullReferenceException when subscribing to an event'
- Added overloads to
Verify
to acceptTimes
as a Method Group - Feature request:
It.IsIn(..)
,It.IsNotIn(...)
- Corrected Verify method behavior for generic methods calls
- Differentiate verification error from mock crash
- Fix: Adding (and removing) handlers for events declared on interfaces works when
CallBase = true
. - Update to latest Castle
- Fix:
Mock.Of
(Functional Syntax) doesn't work on properties with non-public setters - Fix: Allow to use
CallBase
instead ofReturns
- Fix: Solved Multi-threading issue -
IndexOutOfRangeException
- Capability of mocking delegates (event handlers)
- Linq to Mocks:
Mock.Of<T>(x => x.Id == 23 && x.Title == "Rocks!")
- Fixed issues:
- 87
BadImageFormatException
when using a mock with a Visual Studio generated Accessor object - 166 Unable to use a delegate to mock a function that takes 5 or more parameters.
- 168 Call count failure message never says which is the actual invocation count
- 175
theMock.Object
failing on VS2010 Beta 1 - 177 Generic constraint on interface method causes
BadImageFormatException
when gettingObject
. - 183 Display what invocations were recieved when the expected one hasn't been met
- 186 Methods that are not virtual gives non-sense-exception message
- 188 More
Callback
Overloads - 199 Simplify
SetupAllProperties
implementation to simply iterate and callSetupProperty
- 200 Fluent mock does not honor parent mock
CallBase
setting. - 202
Mock.Protected().Expect()
deprecated with no work-around - 204 Allow default return values to be specified (per-mock)
- 205 Error calling
SetupAllProperties
forMock<IDataErrorInfo>
- 206 Linq-to-Mocks Never Returns on Implicit Boolean Property
- 207
NullReferenceException
thrown when usingMocks.CreateQuery
with implicit boolean expression - 208 Can't setup a mock for method that accept lambda expression as argument.
- 211
SetupAllProperties
should return theMock<T>
instead ofvoid
. - 223 When a method is defined to make the setup an asserts mock fails
- 226 Can't raise events on mocked Interop interfaces
- 229
CallBase
is not working for virtual events - 238 Moq fails to mock events defined in F#
- 239 Use
Func
instead ofPredicate
- 250 4.0 Beta 2 regression - cannot mock
MethodInfo
when targetting .NET 4 - 251 When a generic interface also implements a non-generic version,
Verify
does not work in some cases - 254 Unable to create mock of
EnvDTE.DTE
- 261 Can not use protected setter in public property
- 267 Generic argument as dependency for method
Setup
overrides all previous method setups for a given method - 273 Attempting to create a mock thrown a Type Load exception. The message refers to an inaccessible interface.
- 276 .Net 3.5 no more supported
- 87
- Silverlight support! Finally integrated Jason's Silverlight contribution! Issue #73
- Brand-new simplified event raising syntax (#130):
mock.Raise(foo => foo.MyEvent += null, new MyArgs(...));
- Support for custom event signatures (not compatible with
EventHandler
):mock.Raise(foo => foo.MyEvent += null, arg1, arg2, arg3);
- Substantially improved property setter behavior:
mock.VerifySet(foo => foo.Value = "foo");
(also available forSetupSet
- Renamed
Expect*
withSetup*
- Vastly simplified custom argument matchers:
public int IsOdd() { return Match<int>.Create(v => i % 2 == 0); }
- Added support for verifying how many times a member was invoked:
mock.Verify(foo => foo.Do(), Times.Never());
- Added simple sample app named StoreSample
- Moved Stub functionality to the core API (
SetupProperty
andSetupAllProperties
) - Fixed sample ASP.NET MVC app to work with latest version
- Allow custom matchers to be created with a substantially simpler API
- Fixed issue #145 which prevented discrimination of setups by generic method argument types
- Fixed issue #141 which prevented ref arguments matching value types (i.e. a Guid)
- Implemented improvement #131: Add support for
It.IsAny
and custom argument matchers forSetupSet
/VerifySet
- Implemented improvement #124 to render better error messages
- Applied patch from David Kirkland for improvement #125 to improve matching of enumerable parameters
- Implemented improvement #122 to provide custom errors for
Verify
- Implemented improvement #121 to provide
null
as default value forNullable<T>
- Fixed issue #112 which fixes passing a null argument to a mock constructor
- Implemented improvement #111 to better support params arguments
- Fixed bug #105 about improperly overwriting setups for property getter and setter
- Applied patch from Ihar.Bury for issue #99 related to protected expectations
- Fixed issue #97 on not being able to use
SetupSet
/VerifySet
if property did not have a getter - Better integration with Pex (http://research.microsoft.com/en-us/projects/Pex/)
- Various other minor fixes (#134, #135, #137, #138, #140, etc.)
- Implemented Issue #55: We now provide a
mock.DefaultValue
= [DefaultValue.Empty
|DefaultValue.Mock
] which will provide the current behavior (default) or mocks for mockeable return types for loose mock invocations without expectations. - Added support for stubbing properties from moq-contrib: now you can do
mock.Stub(m => m.Value)
and add stub behavior to the property.mock.StubAll()
is also provided. This integrates with theDefaultValue
behavior too, so you can stub entire hierarchies :). - Added support for mocking methods with
out
andref
parameters (Issue #50) - Applied patch contributed by slava for Issue #72: add support to limit numbor of calls on mocked method (we now have
mock.Expect(...).AtMost(5)
) - Implemented Issue #94: Easier setter verification: Now we support
ExpectSet(m = m.Value, "foo")
andVerifySet(m = m.Value, 5)
(Thanks ASP.NET MVC Team!) - Implemented issue #96: Automatically chain mocks when setting expectations. It's now possible to specify expectations for an entire hierarchy of objects just starting from the root mock. THIS IS REALLY COOL!!!
- Fixed Issue #89:
Expects()
does not always return last expectation - Implemented Issue 91: Expect a method/property to never be called (added
Never()
method to an expectation. Can be used on methods, property getters and setters) - Fixed Issue 86:
IsAny<T>
should check if the value is actually of typeT
- Fixed Issue 88: Cannot mock protected internal virtual methods using
Moq.Protected
- Fixed Issue 90: Removing event handlers from mocked objects
- Updated demo and added one more test for the dynamic addition of interfaces
- Added support for mocking protected members
- Added new way of extending argument matchers which is now very straightforward
- Added support for mocking events
- Added support for firing events from expectations
- Removed usage of MBROs which caused inconsistencies in mocking features
- Added
ExpectGet
andExpectSet
to better support properties, and provide better intellisense. - Added verification with expressions, which better supports Arrange-Act-Assert testing model (can do
Verify(m => m.Do(...)))
- Added
Throws<TException>
- Added
mock.CallBase
property to specify whether the virtual members base implementation should be called - Added support for implementing and setting expectations and verifying additional interfaces in the mock, via the new
mock.As<TInterface>()
method (thanks Fernando Simonazzi!) - Improved argument type matching for
Is
/IsAny
(thanks Jeremy.Skinner!)
- Refactored fluent API on mocks. This may cause some existing tests to fail, but the fix is trivial (just reorder the calls to
Callback
,Returns
andVerifiable
) - Added support for retrieving a
Mock<T>
from aT
instance created by a mock. - Added support for retrieving the invocation arguments from a
Callback
orReturns
. - Implemented
AtMostOnce()
constraint - Added support for creating MBROs with protected constructors
- Loose mocks now return default empty arrays and
IEnumerables
instead ofnull
s
- Refactored
MockFactory
to make it simpler and more explicit to use with regards to verification. Thanks Garry Shutler for the feedback!
- Added
MockFactory
to allow easy construction of multiple mocks with the same behavior and verification
- Added support for passing constructor arguments for mocked classes.
- Improved code documentation
- Added support for overriding expectations set previously on a Mock. Now adding a second expectation for the same method/property call will override the existing one. This facilitates setting up default expectations in a fixture setup and overriding when necessary in a specific test.
- Added support for mock verification. Both
Verify
andVerifyAll
are provided for more flexibility (the former only verifies methods markedVerifiable
)
- Added support for
MockBehavior
mock constructor argument to affect the way the mocks expect or throw on calls.
- Merged branch for dynamic types. Now Moq is based on Castle DynamicProxy2 to support a wider range of mock targets.
- Added ILMerge so that Castle libraries are merged into Moq assembly (no need for external references and avoid conflicts)
- Initial release, initial documentation process in place, etc.