Request: Ability to setup a property of type Task<ConcreteType> by mocking interface
Category
- [x] 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?
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
You should be able to set the return value value to Task.FromResult(Mock.OfType<IInterface>()), I think.
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
This issue will now be closed since it has been labeled 'stale' without activity for 30 days.
