I don't quite understand why WhenArgumentsMatch does not work well with Repeat Always. Here is the test code:
[Test, VerifyMocks]
public void TestMessageBoxNatural2()
{
using(RecordExpectations recorder = RecorderManager.StartRecording())
{
MessageBox.Show("Lita");
recorder.Return(DialogResult.OK).WhenArgumentsMatch("Welcome!");
recorder.RepeatAlways();
}
epsilonT eps = new epsilonT();
eps.MessageBoxShow();
Assert.AreEqual(100.0, eps.Tol);
}
And here's the Logic code:
public class epsilonT
{
private double tol;
public double Tol
{
get { return tol; }
set { tol = value; }
}
public epsilonT()
{
}
// public epsilonT(double wu)
public static bool IsEpsilon(double ptValue)
{
return ptValue==0;
}
public void MessageBoxShow()
{
MessageBox.Show("Welcome!");
MessageBox.Show("Welcome!");
tol = 100.0;
}
}
When I ran the code, only one
MessageBox.Show is mocked away even though I specify that the mock should be
RepeatAlways.
________
hashish