示例#1
0
 object CreateMock(PrigTypeSpecimen specimen, ISpecimenContext context)
 {
     foreach (var stub in specimen.Stubs)
     {
         SetAutoBody(stub, context);
     }
     return(specimen.Object);
 }
示例#2
0
        object CreatePrigType(Type type)
        {
            var methods = type.GetMethods(PublicStatic).Where(_ => typeof(IBehaviorPreparable).IsAssignableFrom(_.ReturnType)).ToArray();

            if (methods.Length == 0)
            {
                return(new NoSpecimen());
            }

            var obj    = default(object);
            var result = new PrigTypeSpecimen(obj);

            foreach (var stub in methods.Where(_ => !_.IsGenericMethod).Select(_ => result.CreateStub(_)).Where(CanBeConfigured))
            {
                result.AddStub(stub);
            }
            return(result);
        }