public bool Create(IAnonymousDataContext context, out object result) { if (context.ResultType == typeof(IModel)) { var model = new Model(); model.Value = context.AnyDouble(0, 1, Distribution.Uniform).ToString() + context.Any(typeof(string)); result = model; return(true); } return(context.CallNextCustomization(out result)); }
/// <summary> /// Creates an object of a specified type. /// </summary> /// <param name="context">The current context.</param> /// <param name="result">The result.</param> /// <returns><c>true</c> if an object was created, otherwise <c>false</c>.</returns> public bool Create(IAnonymousDataContext context, out object result) { if (context.CallNextCustomization(out result)) { return(true); } if (context.ResultType.IsInterface() || context.ResultType.IsAbstract()) { var mock = (Mock)context.Any(typeof(Mock <>).MakeGenericType(context.ResultType)); result = mock.Object; return(true); } return(false); }