Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Ability to setup a property of type Task<ConcreteType> by mocking interface #1460

Open
1 task done
wizofaus opened this issue Feb 1, 2024 · 0 comments
Open
1 task done

Comments

@wizofaus
Copy link

wizofaus commented Feb 1, 2024

Category

  • Feature request

Describe the feature

I'm trying to mock a class in a library that uses concrete types for several of its properties, but I happen to know that the properties are only ever accessed via an interface that the concrete type implements.
This works fine:

        `mock.SetupGet<IInterface>(l => l.Property).Returns(Mock.Of<IInterface>())`

Despite the fact that the mocked type defines "Property" as an object of type "ConcreteType" (presumably it would fail if there were code that relied on Property genuinely being of type "ConcreteType", but so far no such issues).

The issue is that one property is actually of type Task<ConcreteType>, and I want to replace it with mocked Task<IInterface>, and so far I haven't found any syntax that allows that.

If there were a SetupAsync( ) or similar function (matching ReturnsAsync()), I would think it might be possible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant