Skip to content

Improve ForPartsOf to use interface and implementation class instead of class only #625

@wsaeed

Description

@wsaeed

Currently ForPartsOf accepts a single template parameter (a class), which requires the mocked method to be virtual. Making methods of a class virtual allows derived classes to override which may change the behavior of the class.

TImplementation Substitute.For<TImplementation>(...)

https://nsubstitute.github.io/help/partial-subs/

Suggestion is to to have an overload similar to

TInterface Substitute.For<TInterface, TImplementation>(...)

Any methods which are not mocked forwarded to the implementation class.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for a new NSubstitute feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions