Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Add support for being able to proxy existing class instance #72

@tapika

Description

@tapika

By default when you create new Mock, you cannot use existing class instance - meanwhile in Moq v 4 - I've noticed that Castle.DynamicProxy.ProxyGenerator supports providing existing class instance - you can use either CreateInterfaceProxyWithTarget or CreateClassProxyWithTarget - and proxy existing class instance.

I do understand that Moq v5 is slightly different than Moq v4 - but I think its possible to use same concept as well.

So maybe there should be alternative constructor:

class Mock<T>...

      Mock(T t);  // Use by default all methods from t unless overridden by Setup function call.

Which would allow to pass class instance to be proxied.

This feature would be useful in case if want to use majority of same functionality as T defines, by maybe override by couple of methods via Setup.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions