Hi,
The easier way to match any int is:
Isolate.WhenCalled(() => fake.MyFunc(0)).WillReturn(100);
The value that you pass to MyFunc is ignored.
This solves your first issue as well.
You can also write cusom logic for MyFunc.
I prefer the way you initially did it, just thought you should know all possible implementations:
[TestMethod, Isolated]
[ExpectedException(typeof(ArgumentException))]
public void MatchArgumentsUsingPredicate2()
{
var fake = Isolate.Fake.Instance<IMyInterface>();
Isolate.WhenCalled(() => fake.MyFunc(0)).DoInstead(c =>
{
if ((int)c.Parameters[0] > 100)
{
throw new ArgumentException();
}
return 100;
});
int result = fake.MyFunc(1);
Assert.AreEqual(100, result);
// Thow ArgumentException
fake.MyFunc(101);
}