public class simplemocking
{
public interface IFoo
{
int foo ();
}
public void fii()
{
IFoo foo = MockRepository.GenerateMock<IFoo> ();
SetupResult.For (foo.foo ()).Return (5).Repeat.Any ();
Console.WriteLine (foo.foo ());
}
}
Exception:
Invalid call, the last call has been used or no call has been made (make sure that you are calling a virtual (C#) / Overridable (VB) method).
Maybe you can try to use extension methods instead of SetupFor
Replace the second line by:
foo.Stub(f => f.foo()).Return(5).Repeat.Any();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.