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

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

            return(new StepDescriber().Describe(def));
        }
Exemplo 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;
        }
Exemplo 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);
        }
Exemplo 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;
       }
     }
       }
 }
Exemplo n.º 6
0
 public IResult <T> Add(IResult <T> result, IMemberMatcher matcher) =>
 new MultipleResults <T>(matcher)
 .Add(this, matcher)
 .Add(result, matcher);
Exemplo n.º 7
0
 internal SetupNotFoundException(IMemberMatcher message) :
     base(message.ToString())
 {
 }
Exemplo n.º 8
0
 private StepDescription Describe(IMemberMatcher matcher)
 {
     var def = new StepDefinition { DeclaringType = typeof(ExampleContext), Matcher = matcher };
     return new StepDescriber().Describe(def);
 }
Exemplo n.º 9
0
 public override IResult <Void> Add(IResult <Void> result, IMemberMatcher matcher) => result;
Exemplo n.º 10
0
 public Setup(IIntercept <T> interceptor, IMemberMatcher expression, IResult <TResult> result)
 {
     _interceptor = interceptor;
     Expression   = expression;
     Result       = result;
 }
Exemplo n.º 11
0
 private Setup <T, Void> Action(IMemberMatcher matcher) =>
 new Setup <T, Void>(this, matcher, new ActionResult());
Exemplo n.º 12
0
 private static bool FilterOutExtensionMethods(IMemberMatcher matcher)
 {
     var methodInfo = matcher.MemberInfo as MethodInfo;
     return (methodInfo == null) ||
            (!methodInfo.IsDefined(typeof (ExtensionAttribute), true));
 }
Exemplo n.º 13
0
 public UninitializedResult(IMemberMatcher expression) =>
Exemplo 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);
             }
         }
     }
 }
Exemplo n.º 15
0
 private Setup <T, TResult> Uninitialized <TResult>(IMemberMatcher matcher) =>
 new Setup <T, TResult>(this, matcher, new UninitializedResult <TResult>(matcher));
Exemplo n.º 16
0
 internal OutOfResultsException(IMemberMatcher expression) :
     base(expression.ToString())
 {
 }
Exemplo n.º 17
0
 public MultipleResults(IMemberMatcher expression) =>
Exemplo n.º 18
0
 public SetupAsync(IIntercept <T> interceptor, IMemberMatcher expression) :
     base(interceptor, expression, new UninitializedResult <Task <TResult> >(expression))
 {
 }
Exemplo n.º 19
0
 internal UninitializedException(IMemberMatcher message) :
     base(message.ToString())
 {
 }
Exemplo n.º 20
0
 public ISetup <TResult> Load <TResult>(IMemberMatcher m)
 {
     return(_setups.TryGetValue(m, out var setup)
         ? (ISetup <TResult>)setup
         : throw new SetupNotFoundException(m));
 }
Exemplo n.º 21
0
 public override IResult <Task> Add(IResult <Task> result, IMemberMatcher matcher) =>
 result;
Exemplo n.º 22
0
 private Setup <T, Task> AsyncAction(IMemberMatcher matcher) =>
 new Setup <T, Task>(this, matcher, new AsyncActionResult());