コード例 #1
0
        static void SetFeatures(IASContext mock, IASContext context)
        {
            mock.Settings.Returns(context.Settings);
            mock.Features.Returns(context.Features);
            mock.CurrentModel.Returns(context.CurrentModel);
            var visibleExternalElements = context.GetVisibleExternalElements();

            mock.GetVisibleExternalElements().Returns(visibleExternalElements);
            mock.GetCodeModel(null).ReturnsForAnyArgs(x =>
            {
                var src = x[0] as string;
                return(string.IsNullOrEmpty(src) ? null : context.GetCodeModel(src));
            });
            mock.IsImported(null, Arg.Any <int>()).ReturnsForAnyArgs(it =>
            {
                var member = it.ArgAt <MemberModel>(0) ?? ClassModel.VoidClass;
                return(context.IsImported(member, it.ArgAt <int>(1)));
            });
            mock.ResolveType(null, null).ReturnsForAnyArgs(x => context.ResolveType(x.ArgAt <string>(0), x.ArgAt <FileModel>(1)));
            mock.ResolveToken(null, null).ReturnsForAnyArgs(x => context.ResolveToken(x.ArgAt <string>(0), x.ArgAt <FileModel>(1)));
            mock.ResolveDotContext(null, null, false).ReturnsForAnyArgs(it =>
            {
                var expr = it.ArgAt <ASExpr>(1);
                if (expr == null)
                {
                    return(null);
                }
                return(context.ResolveDotContext(it.ArgAt <ScintillaControl>(0), expr, it.ArgAt <bool>(2)));
            });
            mock.IsFileValid.Returns(context.IsFileValid);
            mock.GetDefaultValue(null).ReturnsForAnyArgs(it => context.GetDefaultValue(it.ArgAt <string>(0)));
            mock.DecomposeTypes(null).ReturnsForAnyArgs(it => context.DecomposeTypes(it.ArgAt <IEnumerable <string> >(0) ?? new string[0]));
            mock.Classpath.Returns(context.Classpath);
            mock.CreateFileModel(null).ReturnsForAnyArgs(it => context.CreateFileModel(it.ArgAt <string>(0)));
            var allProjectClasses = context.GetAllProjectClasses();

            mock.GetAllProjectClasses().Returns(allProjectClasses);
            mock.CodeGenerator.Returns(context.CodeGenerator);
        }