Ejemplo n.º 1
0
 private bool DoesContainAssertion(MethodCall methodCall)
 {
     if (!methodCall.HasMethodDefinition || !methodCall.MethodDefinition.HasBody)
         return false;
     var frameworks = new[] {Framework}.Concat(_mockFrameworks);
     return frameworks.Any(fw => fw.DoesContainAssertion(methodCall.MethodDefinition));
 }
Ejemplo n.º 2
0
 private IEnumerable<IList<MethodCall>> AddPathsToRoot(MethodCall call)
 {
     if (!DoesContainAssertion(call))
         return new IList<MethodCall>[0];
     var graph = CallGraph;
     // Create a graph with edges in the other direction so we can
     // backtrack from this method to the test method (root).
     var builder = new GraphBuilder<MethodCall>(graph.TailsFor);
     var backGraph = builder.Build(call);
     return backGraph.FindPaths(call, graph.Root);
 }
Ejemplo n.º 3
0
 private static IEnumerable<MethodCall> CalledMethodsFinder(MethodCall call)
 {
     if (!call.HasMethodDefinition)
         return new MethodCall[0]; // no body to parse anyway
     var definition = call.MethodDefinition;
     return definition.CalledMethods().Where(mc => !mc.MethodReference.Name.Equals(".ctor")).Select(TryResolve);
 }
Ejemplo n.º 4
0
 private static MethodCall TryResolve(MethodCall mc)
 {
     if (mc.HasMethodDefinition)
         return mc;
     MethodReference result;
     try
     {
         result = mc.MethodReference.Resolve();
     }
     catch (AssemblyResolutionException)
     {
         // resolution is best-effort, keep the reference
         result = mc.MethodReference;
     }
     return new MethodCall(mc.Instruction, result);
 }
Ejemplo n.º 5
0
 protected bool Equals(MethodCall other)
 {
     return Equals(Instruction, other.Instruction);
 }