public static IMethodOptions <Task <T> > ReturnAsync <T>(this IMethodOptions <Task <T> > methodOptions, T someValue, TimeSpan?delay = null) { Func <Task <T> > executor = async() => { if (delay != null) { await Task.Delay(delay.Value); } return(someValue); }; return(methodOptions.Return(executor())); }
static public IMethodOptions <IEnumerable <R> > it_will_return <R>(this IMethodOptions <IEnumerable <R> > options, params R[] items) { return(options.Return(items.AsEnumerable())); }
static public IMethodOptions <R> it_will_return <R>(this IMethodOptions <R> options, R item) { return(options.Return(item)); }
public static IMethodOptions <object> Return <T1>(this IMethodOptions <object> options, Func <T1> action) { return(options.Return(action())); }
public static IMethodOptions <T> Return <T>(this IMethodOptions <T> opts, Func <T> factory) { opts.Return(default(T)); // required for Rhino.Mocks on non-void methods opts.WhenCalled(mi => mi.ReturnValue = factory()); return(opts); }
/// <summary> /// Usage: /// _mockRepository.Stub(r => r.Method(active: null)).ReturnAsync(object); /// </summary> /// <typeparam name="T"></typeparam> /// <param name="options"></param> /// <param name="objToReturn"></param> /// <returns></returns> public static IMethodOptions <Task <T> > ReturnAsync <T>(this IMethodOptions <Task <T> > options, T objToReturn) { return(options.Return(Task.FromResult(objToReturn))); }
public static IMethodOptions <T> returns <T>( this IMethodOptions <T> options, T value) { return(options.Return(value)); }
public void Return(TReturnValue returnValue) { _methodOptions.Return(returnValue); }
static public IMethodOptions <ICollection <R> > it_will_return <R>(this IMethodOptions <ICollection <R> > options, params R[] items) { return(options.Return(items.ToList())); }