Ejemplo n.º 1
0
        public static void SetHaxeFeatures(this IASContext mock)
        {
            var currentModel = new FileModel {
                Context = mock, Version = 4, haXe = true
            };
            var context = new HaXeContext.Context(new HaXeContext.HaXeSettings());

            BuildClassPath(context);
            context.CurrentModel = currentModel;
            mock.Settings.LanguageId.Returns(context.Settings.LanguageId);
            mock.Features.Returns(context.Features);
            mock.CurrentModel.Returns(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);
                return(member != null && context.IsImported(member, it.ArgAt <int>(1)));
            });
            mock.ResolveType(null, null).ReturnsForAnyArgs(x => context.ResolveType(x.ArgAt <string>(0), x.ArgAt <FileModel>(1)));
            mock.IsFileValid.Returns(context.IsFileValid);
        }
        public static void SetHaxeFeatures(this IASContext context)
        {
            var currentModel = new FileModel {
                Context = context, Version = 4, haXe = true
            };
            var haxeContext = new HaXeContext.Context(new HaXeContext.HaXeSettings());

            BuildClassPath(haxeContext);
            haxeContext.CurrentModel = currentModel;
            context.Features.Returns(haxeContext.Features);
            context.CurrentModel.Returns(currentModel);
            var visibleExternalElements = haxeContext.GetVisibleExternalElements();

            context.GetVisibleExternalElements().Returns(x => visibleExternalElements);
            context.GetCodeModel(null).ReturnsForAnyArgs(x =>
            {
                var src = x[0] as string;
                return(string.IsNullOrEmpty(src) ? null : haxeContext.GetCodeModel(src));
            });
            context.ResolveType(null, null).ReturnsForAnyArgs(x => haxeContext.ResolveType(x.ArgAt <string>(0), x.ArgAt <FileModel>(1)));
        }