devlooped / devlooped/moq

wrap an existing instance of an interface

Open
#1,651 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
C#
Stars
6.4k
Forks
835
PR merge metrics
No merged PRs in 30d

Description

What I want to do put a mock around around existing instance so I that I verify that the methods are called

IFoo foo = GetFoo();
var mock = new Mock( foo );
mock.Setup(....)

The only way I can see to this is to implement IFoo myself that wraps the foo instance and then do
new Mock(foo)

is there some other way to do this?

Back this issue
Back this issue

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names Mock, IFoo, and an existing IFoo instance; start by reviewing Moq's Mock construction and interception behavior. Determine whether an existing interface instance can be wrapped while preserving method verification, and define completion as either a supported usage path or a clearly scoped feature with tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.