I suggest you ...

Provide a callback before returning default mocks as values

When you set up a Mock with DefaultValue.Mock it will return mock instances for any members that don't have Setups defined.

I'm doing a lot of work with AutoMocking containers, and in that scenario it would be really nice to have a callback that would allow me to intercept this behavior.

My AutoMocking container will take care of returning a mock of IFoo, and with DefaultValue.Mock, a member will automatically return a mock of IBar.

However, I would really like to be able to say that "whenever Moq tries to return IBaz from an IBar method, I want to be able to intercept this and replace the return value with something I explicitly define."

This might be a callback or an interface we can register on a Mock or MockFactory, or perhaps an event...

21 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Mark SeemannMark Seemann shared this idea  ·   ·  Admin →
    planned  ·  kzuAdminkzu (Admin, moq) responded  · 

    yes, we had a request to allow the default value strategy be open (it’s already pluggable internally)

    0 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...

      Feedback and Knowledge Base