protected void GetMethodMockInternal(CallPattern callPattern, int depth, List<MethodMockMatcherTreeNode> results, MatchingOptions matchingOptions) { if (depth == callPattern.ArgumentMatchers.Count + 1) { var resultNode = this.Children.Select(x => x as MethodMockMatcherTreeNode).ToList(); results.AddRange(resultNode); foreach (var result in resultNode) { DebugView.TraceEvent(IndentLevel.Matcher, () => String.Format("Found candidate arrangement (id={0}) {1} {2}", result.Id, result.MethodMock.ArrangementExpression, result.MethodMock.IsSequential ? String.Format("(in sequence, used: {0})", result.MethodMock.IsUsed ? "yes" : "no") : "")); } return; } var matcher = depth == 0 ? callPattern.InstanceMatcher : callPattern.ArgumentMatchers[depth - 1]; var children = this.GetMatchingChildren(matcher, matchingOptions, depth); foreach (var child in children) { child.GetMethodMockInternal(callPattern, depth + 1, results, matchingOptions); } }
private IEnumerable <MatcherTreeNode> GetMatchingChildren(IMatcher matcher, MatchingOptions options, int depth) { switch (options) { case MatchingOptions.Concretizing: return(this.Children.Where(child => TraceMatch(matcher, child.Matcher, depth)).Cast <MatcherTreeNode>()); case MatchingOptions.Generalizing: return(this.Children.Where(child => TraceMatch(child.Matcher, matcher, depth)).Cast <MatcherTreeNode>()); case MatchingOptions.Exact: return(this.Children.Where(child => child.Matcher.Equals(matcher)).Cast <MatcherTreeNode>()); default: throw new ArgumentException("options"); } }
protected void GetMethodMockInternal(CallPattern callPattern, int depth, List <MethodMockMatcherTreeNode> results, MatchingOptions matchingOptions) { if (depth == callPattern.ArgumentMatchers.Count + 1) { var resultNode = this.Children.Select(x => x as MethodMockMatcherTreeNode).ToList(); results.AddRange(resultNode); foreach (var result in resultNode) { DebugView.TraceEvent(IndentLevel.Matcher, () => String.Format("Found candidate arrangement (id={0}) {1} {2}", result.Id, result.MethodMock.ArrangementExpression, result.MethodMock.IsSequential ? String.Format("(in sequence, used: {0})", result.MethodMock.IsUsed ? "yes" : "no") : "")); } return; } var matcher = depth == 0 ? callPattern.InstanceMatcher : callPattern.ArgumentMatchers[depth - 1]; var children = this.GetMatchingChildren(matcher, matchingOptions, depth); foreach (var child in children) { child.GetMethodMockInternal(callPattern, depth + 1, results, matchingOptions); } }
private MatcherTreeNode GetMatchingChild(IMatcher matcher, MatchingOptions options, int depth) { return(this.GetMatchingChildren(matcher, options, depth).FirstOrDefault()); }
private MatcherTreeNode GetMatchingChild(IMatcher matcher, MatchingOptions options, int depth) { return this.GetMatchingChildren(matcher, options, depth).FirstOrDefault(); }
private IEnumerable<MatcherTreeNode> GetMatchingChildren(IMatcher matcher, MatchingOptions options, int depth) { switch (options) { case MatchingOptions.Concretizing: return this.Children.Where(child => TraceMatch(matcher, child.Matcher, depth)).Cast<MatcherTreeNode>(); case MatchingOptions.Generalizing: return this.Children.Where(child => TraceMatch(child.Matcher, matcher, depth)).Cast<MatcherTreeNode>(); case MatchingOptions.Exact: return this.Children.Where(child => child.Matcher.Equals(matcher)).Cast<MatcherTreeNode>(); default: throw new ArgumentException("options"); } }