You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mock<ParentClass> can be substituted for Mock<DerivedClass> Similar to the the way that ParentClass itself could be substituted for DerivedClass. That way you can carry the mock with you in the abstract version (say in a list of Mock<ParentClass> es that contains multiple Mock<DerivedClass> types.
Another option here would be to create a "Get"Mock(Object) where you pass in the mock object and get back the mock instance. Actually both of these would be great features, and would allow users to better test there interface hierarchy.
The text was updated successfully, but these errors were encountered:
Ah, I saw that your post was malformatted and some important bits weren't rendered. Fixed the formatting, now I think I understand what you're asking for.
IIRC the IMock<> interface was added with the intent to support co-/contravariance (never sure which one). It doesn't seem like that ever went anywhere TBH, compared to Mock<>, IMock<> looks far too incomplete to actually be useful.
I'm not sure why you'd need a List<Mock<>> in the first place. Can you give an example where such a list would actuslly be useful?
Another option here would be to create a "Get"Mock(Object) where you pass in the mock object and get back the mock instance.
This method already exists, it's called Mock.Get<>(obj).
So in closing I think it's easier and more realistic to have a List<ParentClass> and put parentClassMock.Objects and derivedClassMock.Objects in there, and if you need to get back the mock, use Mock.Get on those list items.
It would be nice to have a feature such that
Mock<ParentClass>
can be substituted forMock<DerivedClass>
Similar to the the way thatParentClass
itself could be substituted forDerivedClass
. That way you can carry the mock with you in the abstract version (say in a list ofMock<ParentClass>
es that contains multipleMock<DerivedClass>
types.Another option here would be to create a
"Get"Mock(Object)
where you pass in the mock object and get back the mock instance. Actually both of these would be great features, and would allow users to better test there interface hierarchy.The text was updated successfully, but these errors were encountered: