Reputation: 7217
I am unit testing one of my functionalities. Results are OK, but collections of result from method are of type Position
, collection for comparison is of type Mock<IPosition>
. That is why test always fails, because comparison between the two is not correct.
Is there a way I can override default comparison between collections?
Results are of type Position, which implements this interface:
public interface IPosition
{
char HorizontalPosition { get;}
int VerticalPosition { get; }
}
But mock collection is of type Mock<IPosition>
.
Upvotes: 1
Views: 175
Reputation: 28747
You have to modify the collections:
var positions = new List<Position>();
var mocks = new List<Mock<IPosition>>();
YourComparisonMethod(positions.Cast<IPosition>(), mocks.Select(m => m.Object));
Upvotes: 2