public ExpressionKind EatVariableType([NotNull] ISnapshot snapshot, [NotNull] IType type) { if (snapshot == null) { throw new ArgumentNullException("snapshot"); } if (type == null) { throw new ArgumentNullException("type"); } var classType = _eatExpressionHelper.GetTypeClass(type); if (snapshot.IsInTestScope(classType.Module.Name)) { //TODO if type is interface or abstract class return stub/mock? return(ExpressionKind.Target); } if (snapshot.IsInTestProject(classType.Module.Name)) { return(ExpressionKind.Mock); } return(ExpressionKind.StubCandidate); }
private ExpressionKind GetCreationObjectKind(ISnapshot snapshot, IObjectCreationExpression expression) { if (expression.Type().Classify == TypeClassification.REFERENCE_TYPE) { var projectName = GetProjectName(expression); if (snapshot.IsInTestScope(projectName)) { return(ExpressionKind.Target); } if (snapshot.IsInTestProject(projectName)) { return(ExpressionKind.Mock); } if (_expressionHelper.GetCreationTypeName(expression) .StartsWith("Moq.Mock")) { return(ExpressionKind.Mock); } } return(ExpressionKind.StubCandidate); }
public ExpressionKind EatCastType([NotNull] ISnapshot snapshot, [NotNull] ITypeUsage typeUsage) { if (snapshot == null) { throw new ArgumentNullException("snapshot"); } if (typeUsage == null) { throw new ArgumentNullException("typeUsage"); } if (typeUsage is IDynamicTypeUsage) { return(ExpressionKind.StubCandidate); } if (typeUsage is IPredefinedTypeUsage) { return(ExpressionKind.StubCandidate); } if (typeUsage is IUserTypeUsage) { var userTypeUsage = typeUsage as IUserTypeUsage; var classType = _eatExpressionHelper.GetUserTypeUsageClass(userTypeUsage); if (snapshot.IsInTestScope(classType.Module.Name)) { return(ExpressionKind.Target); } if (snapshot.IsInTestProject(classType.Module.Name)) { return(ExpressionKind.Mock); } } return(ExpressionKind.StubCandidate); }