I am mocking chessboard, on which I can add pieces. I want to unit test allowed LinearMoves, when there are some pieces on the chessboard.
Code starts with:
Chessboard.Setup(x => x.GetPiece(C1.Object)).Returns(Piece_C1.Object);
Chessboard.Setup(x => x.GetPiece(A3.Object)).Returns(Piece_A3.Object);
linearMoves = new LinearMoves(Chessboard.Object, Piece_A1.Object);
IPiece currentPiece = chessboard.GetPiece(currentPosition);
The problem is that Position is a reference type,so two objects are equal only if they point to the same object.
You need to help your setup method compare Positions
chessboard.Setup(x => x.GetPiece(It.Is< Position>(k => k.X== "A" && K.Y ==3))).Returns(...);