wrap an existing instance of an interface
Nobody has claimed this yet.
- 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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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
