Changelog History
Page 1
-
v4.18.2 Changes
August 02, 2022π Changed
- β‘οΈ Update package reference to
Castle.Core(DynamicProxy) from version 5.0.0 to 5.1.0 (@stakx, #1275) - β Removed dependency on
System.Threading.Tasks.Extensionsfornetstandard2.1andnet6.0(@tibel, #1274)
π Fixed
- "Expression is not an event add" when using
.Raises()with redeclared event (@howcheng, #1175) - π€‘
MissingMethodExceptionwhen mocking interface with sealed default implementation (@pjquirk, #1209) - π€‘ Throws
TypeLoadExceptionon mock when a record has a base record on .NET 6 (@tgrieger-sf, #1273)
- β‘οΈ Update package reference to
-
v4.18.1 Changes
May 16, 2022π Fixed
- β‘οΈ Regression with lazy evaluation of
It.Ispredicates in setup expressions after updating from 4.13.1 to 4.16.1 (@b3go, #1217) - Regression with
SetupPropertywhere Moq fails to match a property accessor implementation against its definition in an interface (@Naxemar, #1248) - π€‘ Difference in behavior when mocking async method using
.Resultvs without (@cyungmann, #1253)
- β‘οΈ Regression with lazy evaluation of
-
v4.18.0 Changes
May 12, 2022π New major version of DynamicProxy (you may get better performance!), so please update with care.
π Changed
- β‘οΈ Update package reference to
Castle.Core(DynamicProxy) from version 4.4.1 to 5.0.0 (@stakx, #1257) - π Adjusted our target frameworks to match DynamicProxy's (see their discussion about which frameworks to target):
- minimum .NET Framework version raised from
net45tonet462 - additional
net6.0TFM
- minimum .NET Framework version raised from
π Fixed
- Can't set up "private protected" properties (@RobSiklos, #1170)
- Using [...] an old version of
System.Net.Httpwhich is vulnerable to "DoS", "Spoofing", "Privilege Escalation", "Authentication Bypass" and "Information Exposure" (@sidseter, #1219) - π§ Failure when invoking a method with by-ref parameter & mockable return type on a mock with
CallBaseandDefaultValue.Mockconfigured (@IanKemp, #1249)
- β‘οΈ Update package reference to
-
v4.17.2 Changes
March 06, 2022π Fixed
- π€‘ Regression: Property stubs not working on sub mock (@aaronburro, #1240)
- π§ Failure when invoking a method with by-ref parameter & mockable return type on a mock with
CallBaseandDefaultValue.Mockconfigured (@IanKemp, #1249)
-
v4.17.1 Changes
February 26, 2022β Added
- π€‘
SetupSet,VerifySetmethods formock.Protected().As<>()(@tonyhallett, #1165) - π New
Throwsmethod overloads that allow specifying a function with or without parameters, to provide an exception, for example.Throws(() => new InvalidOperationException())andSetup(x => x.GetFooAsync(It.IsAny<string>()).Result).Throws((string s) => new InvalidOperationException(s)). (@adam-knights, #1191)
π Changed
- β‘οΈ Update package reference to
Castle.Core(DynamicProxy) from version 4.4.0 to 4.4.1 (@stakx, #1233)
π Fixed
- The guard against unmatchable matchers (added in #900) was too strict; relaxed it to enable an alternative user-code shorthand
_forIt.IsAny<>()(@adamfk, #1199) - π€‘
mock.Protected()setup methods fail when argument is of typeExpression(@tonyhallett, #1189) - Parameter is invalid in
Protected().SetupSet()...VerifySet(@tonyhallett, #1186) - π€‘ Virtual properties and automocking not working for
mock.Protected().As<>()(@tonyhallett, #1185) - π€‘ Issue mocking VB.NET class with overloaded property/indexer in base class (@myurashchyk, #1153)
- β
Equivalent arrays don't test equal when returned from a method, making
Verifyfail when it should not (@evilc0, #1225) - π€‘ Property setups are ignored on mocks instantiated using
Mock.Of(@stakx, #1066) - π€‘
SetupAllPropertiescauses mocks to become race-prone (@estrizhok, #1231)
- π€‘
-
v4.17.0 Changes
This version was skipped due to an intermittent NuGet publishing issue.
-
v4.16.1 Changes
February 23, 2021β Added
- 0οΈβ£
CallBasecan now be used with interface methods that have a default interface implementation. It will call the most specific override. (@stakx, #1130)
π Changed
- π Improved error message formatting of
It.Islambda expressions that capture local variables. (@bfriesen, #1140)
π Fixed
AmbiguousMatchExceptionraised when interface has property indexer besides property in VB. (@mujdatdinc, #1129)- 0οΈβ£ Interface default methods are ignored (@hahn-kev, #972)
- Callback validation too strict when setting up a task's
.Resultproperty (@stakx, #1132) setup.Returns(InvocationFunc)wraps thrown exceptions inTargetInvocationException(@stakx, #1141)
- 0οΈβ£
-
v4.16.0 Changes
January 16, 2021β Added
- Ability to directly set up the
.Resultof tasks and value tasks, which makes setup expressions more uniform by rendering dedicated async verbs like.ReturnsAsync,.ThrowsAsync, etc. unnecessary:
-mock.Setup(x => x.GetFooAsync()).ReturnsAsync(foo) +mock.Setup(x => x.GetFooAsync().Result).Returns(foo)This is useful in places where there currently aren't any such async verbs at all:
-Mock.Of<X>(x => x.GetFooAsync() == Task.FromResult(foo)) +Mock.Of<X>(x => x.GetFooAsync().Result == foo)This also allows recursive setups / method chaining across async calls inside a single setup expression:
-mock.Setup(x => x.GetFooAsync()).ReturnsAsync(Mock.Of<IFoo>(f => f.Bar == bar)) +mock.Setup(x => x.GetFooAsync().Result.Bar).Returns(bar)or, with only
Mock.Of:-Mock.Of<X>(x => x.GetFooAsync() == Task.FromResult(Mock.Of<IFoo>(f => f.Bar == bar))) +Mock.Of<X>(x => x.GetFooAsync().Result.Bar == bar)This should work in all principal setup methods (
Mock.Of,mock.Setupβ¦,mock.Verifyβ¦). Support inmock.Protected()and for custom awaitable types may be added in the future. (@stakx, #1126)π Changed
- Attempts to mark conditionals setup as verifiable are once again allowed; it turns out that forbidding it (as was done in #997 for version 4.14.0) is in fact a regression. (@stakx, #1121)
π Fixed
π Performance regression: Adding setups to a mock becomes slower with each setup (@CeesKaas, #1110)
π€‘ Regression:
mock.Verify[All]no longer marks invocations as verified if they were matched by conditional setups. (@Lyra2108, #1114)
- Ability to directly set up the
-
v4.15.2 Changes
November 26, 2020π Changed
- β¬οΈ Upgraded
System.Threading.Tasks.Extensionsdependency to version 4.5.4 (@JeffAshton, #1108)
- β¬οΈ Upgraded
-
v4.15.1 Changes
November 10, 2020β Added
- π New method overloads for
It.Is,It.IsIn, andIt.IsNotInthat compare values using a customIEqualityComparer<T>(@weitzhandler, #1064) - π New properties
ReturnValueandExceptiononIInvocationto query recorded invocations return values or exceptions (@MaStr11, #921, #1077) - π Support for "nested" type matchers, i.e. type matchers that appear as part of a composite type (such as
It.IsAnyType[]orFunc<It.IsAnyType, bool>). Argument match expressions likeIt.IsAny<Func<It.IsAnyType, bool>>()should now work as expected, whereas they previously didn't. In this particular example, you should no longer need a workaround like(Func<It.IsAnyType, bool>)It.IsAny<object>()as originally suggested in #918. (@stakx, #1092)
π Changed
- π Event accessor calls (
+=and-=) now get consistently recorded inMock.Invocations. This previously wasn't the case for backwards compatibility withVerifyNoOtherCalls(which got implemented before it was possible to check them usingVerify{Add,Remove}). You now need to explicitly verify expected calls to event accessors prior toVerifyNoOtherCalls. Verification of+=and-=now works regardless of whether or not you set those up (which makes it consistent with how verification usually works). (@80O, @stakx, #1058, #1084) - π¦ Portable PDB (debugging symbols) are now embedded in the main library instead of being published as a separate NuGet symbols package (`.snupkg) (@kzu, #1098)
π Fixed
- π€‘
SetupPropertyfails if property getter and setter are not both defined in mocked type (@stakx, #1017) - Expression tree argument not matched when it contains a captured variable – evaluate all captures to their current values when comparing two expression trees (@QTom01, #1054)
- π€‘ Failure when parameterized
Mock.Of<>is used in query comprehensionfromclause (@stakx, #982)
- π New method overloads for