Open wizofaus opened 7 months ago
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.
Category
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:
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 mockedTask<IInterface>
, and so far I haven't found any syntax that allows that.If there were a
SetupAsync( )
or similar function (matchingReturnsAsync()
), I would think it might be possible?