Esempio n. 1
0
        private static bool FilterOutExtensionMethods(IMemberMatcher matcher)
        {
            var methodInfo = matcher.MemberInfo as MethodInfo;

            return((methodInfo == null) ||
                   (!methodInfo.IsDefined(typeof(ExtensionAttribute), true)));
        }
Esempio n. 2
0
        private StepDescription Describe(IMemberMatcher matcher)
        {
            var def = new StepDefinition {
                DeclaringType = typeof(ExampleContext), Matcher = matcher
            };

            return(new StepDescriber().Describe(def));
        }
Esempio n. 3
0
        private StepDefinition BuildStepDefinition(Type type, IMemberMatcher memberMatcher, int levels)
        {
            var stepDefinition = new StepDefinition { DeclaringType = type, Matcher = memberMatcher };

            if (levels > 0 && memberMatcher.ReturnType != null && memberMatcher.ReturnType != typeof (void))
                stepDefinition.Children = GetStepsForType(memberMatcher.ReturnType, levels - 1, x=>true);
            else
                stepDefinition.Children = new StepDefinition[0];

            return stepDefinition;
        }
Esempio n. 4
0
        private StepDefinition BuildStepDefinition(Type type, IMemberMatcher memberMatcher, int levels)
        {
            var stepDefinition = new StepDefinition {
                DeclaringType = type, Matcher = memberMatcher
            };

            if (levels > 0 && memberMatcher.ReturnType != null && memberMatcher.ReturnType != typeof(void))
            {
                stepDefinition.Children = GetStepsForType(memberMatcher.ReturnType, levels - 1, x => true);
            }
            else
            {
                stepDefinition.Children = new StepDefinition[0];
            }

            return(stepDefinition);
        }
Esempio n. 5
0
 public IEnumerable<MemberReference> FindMembers(AssemblyDefinition assembly, IMemberMatcher matcher)
 {
     foreach (TypeDefinition type in assembly.MainModule.Types)
       {
     foreach (PropertyDefinition property in type.Properties)
     {
       if (matcher.Includes(property))
       {
     yield return property;
       }
     }
     foreach (MethodDefinition method in type.Methods)
     {
       if (matcher.Includes(method))
       {
     yield return method;
       }
     }
       }
 }
Esempio n. 6
0
 public IResult <T> Add(IResult <T> result, IMemberMatcher matcher) =>
 new MultipleResults <T>(matcher)
 .Add(this, matcher)
 .Add(result, matcher);
Esempio n. 7
0
 internal SetupNotFoundException(IMemberMatcher message) :
     base(message.ToString())
 {
 }
Esempio n. 8
0
 private StepDescription Describe(IMemberMatcher matcher)
 {
     var def = new StepDefinition { DeclaringType = typeof(ExampleContext), Matcher = matcher };
     return new StepDescriber().Describe(def);
 }
Esempio n. 9
0
 public override IResult <Void> Add(IResult <Void> result, IMemberMatcher matcher) => result;
Esempio n. 10
0
 public Setup(IIntercept <T> interceptor, IMemberMatcher expression, IResult <TResult> result)
 {
     _interceptor = interceptor;
     Expression   = expression;
     Result       = result;
 }
Esempio n. 11
0
 private Setup <T, Void> Action(IMemberMatcher matcher) =>
 new Setup <T, Void>(this, matcher, new ActionResult());
Esempio n. 12
0
 private static bool FilterOutExtensionMethods(IMemberMatcher matcher)
 {
     var methodInfo = matcher.MemberInfo as MethodInfo;
     return (methodInfo == null) ||
            (!methodInfo.IsDefined(typeof (ExtensionAttribute), true));
 }
Esempio n. 13
0
 public UninitializedResult(IMemberMatcher expression) =>
Esempio n. 14
0
 public IEnumerable <MemberReference> FindMembers(AssemblyDefinition assembly, IMemberMatcher matcher)
 {
     foreach (TypeDefinition type in assembly.MainModule.Types)
     {
         foreach (PropertyDefinition property in type.Properties)
         {
             if (matcher.Includes(property))
             {
                 yield return(property);
             }
         }
         foreach (MethodDefinition method in type.Methods)
         {
             if (matcher.Includes(method))
             {
                 yield return(method);
             }
         }
     }
 }
Esempio n. 15
0
 private Setup <T, TResult> Uninitialized <TResult>(IMemberMatcher matcher) =>
 new Setup <T, TResult>(this, matcher, new UninitializedResult <TResult>(matcher));
Esempio n. 16
0
 internal OutOfResultsException(IMemberMatcher expression) :
     base(expression.ToString())
 {
 }
Esempio n. 17
0
 public MultipleResults(IMemberMatcher expression) =>
Esempio n. 18
0
 public SetupAsync(IIntercept <T> interceptor, IMemberMatcher expression) :
     base(interceptor, expression, new UninitializedResult <Task <TResult> >(expression))
 {
 }
Esempio n. 19
0
 internal UninitializedException(IMemberMatcher message) :
     base(message.ToString())
 {
 }
Esempio n. 20
0
 public ISetup <TResult> Load <TResult>(IMemberMatcher m)
 {
     return(_setups.TryGetValue(m, out var setup)
         ? (ISetup <TResult>)setup
         : throw new SetupNotFoundException(m));
 }
Esempio n. 21
0
 public override IResult <Task> Add(IResult <Task> result, IMemberMatcher matcher) =>
 result;
Esempio n. 22
0
 private Setup <T, Task> AsyncAction(IMemberMatcher matcher) =>
 new Setup <T, Task>(this, matcher, new AsyncActionResult());