Skip to content

Releases: devlooped/moq

4.15.1

30 Dec 11:54
Compare
Choose a tag to compare

Added

  • New method overloads for It.Is, It.IsIn, and It.IsNotIn that compare values using a custom IEqualityComparer<T> (@weitzhandler, #1064)
  • New properties ReturnValue and Exception on IInvocation to 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[] or Func<It.IsAnyType, bool>). Argument match expressions like It.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 in Mock.Invocations. This previously wasn't the case for backwards compatibility with VerifyNoOtherCalls (which got implemented before it was possible to check them using Verify{Add,Remove}). You now need to explicitly verify expected calls to event accessors prior to VerifyNoOtherCalls. 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

  • SetupProperty fails 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 comprehension from clause (@stakx, #982)

4.14.7

30 Dec 11:54
Compare
Choose a tag to compare

Changed

  • Mocks created by DefaultValue.Mock now inherit SetupAllProperties from their "parent" mock (like it says in the XML documentation) (@stakx, #1074)

Fixed

  • Setup not triggered due to VB.NET transparently inserting superfluous type conversions into a setup expression (@InteXX, #1067)
  • Nested mocks created by Mock.Of<T>() no longer have their properties stubbed since version 4.14.0 (@vruss, @1071)
  • Verify fails for recursive setups not explicitly marked as Verifiable (@killergege, #1073)
  • Mock.Of<> fails for COM interop types that are annotated with a [CompilerGenerated] custom attribute (@killergege, #1072)

4.14.6

30 Dec 11:55
Compare
Choose a tag to compare

Fixed

  • Regression since 4.14.0: setting nested non-overridable properties via Mock.Of (@mariotee, #1039)

4.14.5

30 Dec 11:55
Compare
Choose a tag to compare

Fixed

  • Regression since version 4.11.0: VerifySet fails with NullReferenceException for write-only indexers (@Epicycle23, #1036)

4.14.4

30 Dec 11:56
Compare
Choose a tag to compare

Fixed

  • Regression: NullReferenceException on subsequent setup if expression contains null reference (@IanYates83, #1031)

4.14.3

30 Dec 11:56
Compare
Choose a tag to compare

Fixed

  • Regression, Part II: Verify behavior change using DefaultValue.Mock (@DesrosiersC, #1024)

4.14.2

30 Dec 11:56
Compare
Choose a tag to compare

Fixed

4.14.1

30 Dec 11:57
d5552d5
Compare
Choose a tag to compare

Added

  • New SetupSequence verbs .PassAsync() and .ThrowsAsync(...) for async methods with void return type (@fuzzybair, #993)

Fixed

  • StackOverflowException on VerifyAll when mocked method returns mocked object (@hotchkj, #1012)

4.14.0

30 Dec 11:57
14f2157
Compare
Choose a tag to compare

Added

  • A mock's setups can now be inspected and individually verified via the new Mock.Setups collection and IInvocation.MatchingSetup property (@stakx, #984-#987, #989, #995, #999)

  • New .Protected().Setup and Protected().Verify method overloads to deal with generic methods (@JmlSaul, #967)

  • Two new public methods in Times: bool Validate(int count) and string ToString() (@stakx, 975)

Changed

  • Attempts to mark conditionals setup as verifiable are now considered an error, since conditional setups are ignored during verification. Calls to .Verifiable() on conditional setups are no-ops and can be safely removed. (@stakx, #997)

  • When matching invocations against setups, captured variables nested inside expression trees are now evaluated. Their values likely matter more than their identities. (@stakx, #1000)

Fixed

  • Regression: Restored Capture.In use in mock.Verify(expression, ...) to extract arguments of previously recorded invocations. (@vgriph, #968; @stakx, #974)

  • Consistency: When mocking a class C whose constructor invokes one of its virtual members, Mock.Of<C>() now operates like new Mock<C>(): a record of such invocations is retained in the mock's Invocations collection (@stakx, #980)

  • After updating Moq from 4.10.1 to 4.11, mocking NHibernate session throws a System.NullReferenceException (@ronenfe, #955)

4.13.1

30 Dec 11:58
1568848
Compare
Choose a tag to compare

Fixed

  • SetupAllProperties does not recognize property as read-write if only setter is overridden (@stakx, #886)

  • Regression: InvalidCastException caused by Moq erroneously reusing a cached auto-mocked (DefaultValue.Mock) return value for a different generic method instantiation (@BrunoJuchli, #932)

  • AmbiguousMatchException when setting up the property, that hides another one (@ishatalkin, #939)

  • ArgumentException ("Interface not found") when setting up object.ToString on an interface mock (@vslynko, #942)

  • Cannot "return" to original mocked type after downcasting with Mock.Get and then upcasting with mock.As<> (@pjquirk, #943)

  • params arrays in recursive setup expressions are matched by reference equality instead of by structural equality (@danielcweber, #946)

  • mock.SetupProperty throws NullReferenceException when called for partially overridden property (@stakx, #951)