For example I have
interface ICommand {}
class MovePiece : ICommand {}
class Successful<CMD> where CMD : ICommand {}
and I want the following:
CovariantlyEqual(
typeof(Successful<ICommand>),
typeof(Successful<MovePiece>))
.ShouldEqualTrue()
Update Eric asks below why I would want to test such a thing. Fair enough. I think there are many occasions where the ability to check this "equality" easily would be useful. Take a simple event aggregator as an example - you want to be able to tell it that you are interested to subscribing to all successful commands. Meanwhile another component can be interested in only a successful MovePiece event.
I guess I am wrong but I thought this was what co and contra variance was all about. Maybe equality is the wrong term here, but clearly there is some sort of relationship between the type definition Successful<MovePiece>
and Successful<ICommmand>
is there nothing in the language that exposes it easily?