I'm writing a unit test code for a GameBoard object that's part of a project to make the card game "Dominion" in C#. I'm using rhino mocks to test a method that runs a while(! GameIsOver). Inside, the next player is gotten, then called on to take their turn. A lot of this code is not implemented yet (player.takeTurn() is empty for example).
In my unit test, I'm using Rhino Mocks to override the method GameIsOver to return false several times, then return true to end the test at the expected time, but I need to use CallOriginalMethod to call the method I'm testing in GameBoard. The lines that use that method are telling me that CallOriginalMethod is obsolete and requires "original call options" which I have been unable to find any documentation on.
[TestMethod]
public void TestTurnOrderUsingMocks()
{
MockRepository mocks = new MockRepository();
GameBoard fakeBoard = mocks.DynamicMock<GameBoard>();
Player p1 = mocks.DynamicMock<Player>();
Player p2 = mocks.DynamicMock<Player>();
Dictionary<Card, int> cards = GetTestDeck();
using (mocks.Ordered())
{
fakeBoard.PlayGame();
for (int i = 0; i < 10; i++)
{
p1.TakeTurn();
p2.TakeTurn();
}
}
Expect.Call(fakeBoard.AddPlayer(p1)).CallOriginalMethod();
Expect.Call(fakeBoard.AddPlayer(p2)).CallOriginalMethod();
Expect.Call((()=>fakeBoard.PlayGame())).CallOriginalMethod();
Expect.Call(fakeBoard.GameIsOver()).Repeat.Times(20).Return(false);
Expect.Call(fakeBoard.GameIsOver()).Return(true);
mocks.ReplayAll();
fakeBoard.PlayGame();
mocks.VerifyAll();
}
public Boolean AddPlayer(Player p)
{
if (turnOrder.Contains(p))
{
Console.WriteLine("that player has already been added!");
return false;
}
turnOrder.Enqueue(p);
return true;
}
public virtual void PlayGame()
{
while (!GameIsOver())
{
NextPlayer().TakeTurn();
}
}