コードに例外がある場合、再試行ロジックを実装しようとしています。コードを記述し、RhinoMocksにシナリオをシミュレートさせようとしています。コードの要点は次のとおりです。
class Program
{
static void Main(string[] args)
{
MockRepository repo = new MockRepository();
IA provider = repo.CreateMock<IA>();
using (repo.Record())
{
SetupResult.For(provider.Execute(23))
.IgnoreArguments()
.Throw(new ApplicationException("Dummy exception"));
SetupResult.For(provider.Execute(23))
.IgnoreArguments()
.Return("result");
}
repo.ReplayAll();
B retryLogic = new B { Provider = provider };
retryLogic.RetryTestFunction();
repo.VerifyAll();
}
}
public interface IA
{
string Execute(int val);
}
public class B
{
public IA Provider { get; set; }
public void RetryTestFunction()
{
string result = null;
//simplified retry logic
try
{
result = Provider.Execute(23);
}
catch (Exception e)
{
result = Provider.Execute(23);
}
}
}
発生しているように見えるのは、例外が1回だけではなく、毎回スローされることです。設定をどのように変更すればよいですか?