Esempio n. 1
0
 public void TearDown()
 {
     _statusBar = null;
     _dte       = null;
     _host      = null;
     _hostRaw   = null;
 }
Esempio n. 2
0
        private void Create()
        {
            _factory                        = new MockRepository(MockBehavior.Strict);
            _adapter                        = _factory.Create <IVsAdapter>();
            _undoManagerProvider            = _factory.Create <ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService   = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();
            _statusBar                      = _factory.Create <StatusBar>();
            _shell = _factory.Create <IVsUIShell4>();
            _dte   = _factory.Create <_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create <ITextManager>();

            var sp = _factory.Create <SVsServiceProvider>();

            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_shell.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _textManager.Object,
                _factory.Create <ITextDocumentFactoryService>().Object,
                _editorOperationsFactoryService.Object,
                sp.Object);
            _host = _hostRaw;
        }
Esempio n. 3
0
        protected AbstractVimEdition(IVimHost host, int repeat)
        {
            Debug.Assert(repeat != 0);

            this.Repeat = repeat;
            this.ModeSwitched = false;
            this.NewMode = null;
        }
Esempio n. 4
0
        public ModeInsert(IVimHost host, IVimMode previousMode, AbstractVimEditionInsertText causedEdition)
        {
            _insertArea = new VimSpan(host.CurrentPosition, host.CurrentPosition);

            this.Host = host;
            this.CausedEdition = causedEdition;
            this.PreviousMode = previousMode;
        }
Esempio n. 5
0
        private void Create()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _adapter = _factory.Create <IVsAdapter>();
            _adapter.Setup(x => x.IsWatchWindowView(It.IsAny <ITextView>())).Returns(false);
            _adapter.Setup(x => x.IsTextEditorView(It.IsAny <ITextView>())).Returns(true);
            _undoManagerProvider            = _factory.Create <ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService   = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();
            _statusBar = _factory.Create <StatusBar>();
            _uiVSShell = _factory.Create <IVsUIShell4>();
            _vsShell   = _factory.Create <IVsShell>(MockBehavior.Loose);
            _dte       = _factory.Create <_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create <ITextManager>();
            _textManager.Setup(x => x.GetDocumentTextViews(DocumentLoad.RespectLazy)).Returns(new List <ITextView>());
            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(MockBehavior.Loose);
            _extensionAdapterBroker = _factory.Create <IExtensionAdapterBroker>(MockBehavior.Loose);
            _clipboardDevice        = _factory.Create <IClipboardDevice>(MockBehavior.Loose);

            var  vsMonitorSelection = _factory.Create <IVsMonitorSelection>();
            uint selectionCookie    = 42;

            vsMonitorSelection.Setup(x => x.AdviseSelectionEvents(It.IsAny <IVsSelectionEvents>(), out selectionCookie)).Returns(VSConstants.S_OK);

            var  vsRunningDocumentTable     = _factory.Create <IVsRunningDocumentTable>();
            uint runningDocumentTableCookie = 86;

            vsRunningDocumentTable.Setup(x => x.AdviseRunningDocTableEvents(It.IsAny <IVsRunningDocTableEvents3>(), out runningDocumentTableCookie)).Returns(VSConstants.S_OK);

            var sp = _factory.Create <SVsServiceProvider>();

            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_uiVSShell.Object);
            sp.Setup(x => x.GetService(typeof(SVsShell))).Returns(_vsShell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create <IVsExtensibility>().Object);
            sp.Setup(x => x.GetService(typeof(SVsShellMonitorSelection))).Returns(vsMonitorSelection.Object);
            sp.Setup(x => x.GetService(typeof(SVsRunningDocumentTable))).Returns(vsRunningDocumentTable.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create <ITextBufferFactoryService>().Object,
                _factory.Create <ITextEditorFactoryService>().Object,
                _factory.Create <ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                _factory.Create <ISmartIndentationService>().Object,
                _textManager.Object,
                _factory.Create <ISharedServiceFactory>(MockBehavior.Loose).Object,
                _vimApplicationSettings.Object,
                _extensionAdapterBroker.Object,
                ProtectedOperations,
                _factory.Create <IMarkDisplayUtil>(MockBehavior.Loose).Object,
                _factory.Create <IControlCharUtil>(MockBehavior.Loose).Object,
                sp.Object,
                _clipboardDevice.Object);
            _host = _hostRaw;
        }
Esempio n. 6
0
 internal VsVimKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter              = adapter;
     _reportDesignerUtil   = reportDesignerUtil;
     _bufferCoordinator    = bufferCoordinator;
     _vimHost              = bufferCoordinator.VimBuffer.Vim.VimHost;
     _searchInProgressInfo = new Lazy <PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
Esempio n. 7
0
 internal VsVimKeyProcessor(IVsAdapter adapter, IVimBufferCoordinator bufferCoordinator, IKeyUtil keyUtil, IReportDesignerUtil reportDesignerUtil)
     : base(bufferCoordinator.VimBuffer, keyUtil)
 {
     _adapter = adapter;
     _reportDesignerUtil = reportDesignerUtil;
     _bufferCoordinator = bufferCoordinator;
     _vimHost = bufferCoordinator.VimBuffer.Vim.VimHost;
     _searchInProgressInfo = new Lazy<PropertyInfo>(FindSearchInProgressPropertyInfo);
 }
Esempio n. 8
0
 internal VsVimFactoryService(
     IVim vim,
     IVsEditorAdaptersFactoryService adaptersFactory,
     IVimHost vimHost
     )
 {
     _vim = vim;
     _adaptersFactory = adaptersFactory;
     _vimHost = vimHost;
 }
Esempio n. 9
0
        internal static CommandUtil CreateCommandUtil(
            ITextView textView,
            ICommonOperations operations                     = null,
            IMotionUtil motionUtil                           = null,
            IStatusUtil statusUtil                           = null,
            IRegisterMap registerMap                         = null,
            IMarkMap markMap                                 = null,
            IVimData vimData                                 = null,
            IVimLocalSettings localSettings                  = null,
            IUndoRedoOperations undoRedOperations            = null,
            ISmartIndentationService smartIndentationService = null,
            IFoldManager foldManager                         = null,
            IVimHost vimHost                                 = null,
            IMacroRecorder recorder                          = null,
            ISearchService searchService                     = null,
            ITextStructureNavigator wordNavigator            = null,
            IJumpList jumpList                               = null)
        {
            statusUtil              = statusUtil ?? new StatusUtil();
            undoRedOperations       = undoRedOperations ?? VimUtil.CreateUndoRedoOperations(statusUtil);
            localSettings           = localSettings ?? new LocalSettings(new GlobalSettings());
            registerMap             = registerMap ?? CreateRegisterMap(MockObjectFactory.CreateClipboardDevice().Object);
            markMap                 = markMap ?? new MarkMap(new TrackingLineColumnService());
            vimData                 = vimData ?? new VimData();
            motionUtil              = motionUtil ?? CreateTextViewMotionUtil(textView, markMap: markMap, vimData: vimData, settings: localSettings);
            operations              = operations ?? CreateCommonOperations(textView, localSettings, vimData: vimData, statusUtil: statusUtil);
            smartIndentationService = smartIndentationService ?? CreateSmartIndentationService();
            foldManager             = foldManager ?? CreateFoldManager(textView.TextBuffer);
            searchService           = searchService ?? CreateSearchService(localSettings.GlobalSettings);
            wordNavigator           = wordNavigator ?? CreateTextStructureNavigator(textView.TextBuffer, WordKind.NormalWord);
            jumpList                = jumpList ?? CreateJumpList();
            vimHost                 = vimHost ?? new MockVimHost();
            var vim = MockObjectFactory.CreateVim(
                registerMap: registerMap,
                map: markMap,
                host: vimHost,
                vimData: vimData,
                recorder: recorder,
                searchService: searchService);
            var buffer = MockObjectFactory.CreateVimBuffer(
                textView: textView,
                settings: localSettings,
                motionUtil: motionUtil,
                vim: vim.Object,
                wordNavigator: wordNavigator,
                jumpList: jumpList);

            return(new CommandUtil(
                       buffer.Object,
                       operations,
                       statusUtil,
                       undoRedOperations,
                       smartIndentationService,
                       foldManager));
        }
Esempio n. 10
0
        public void InitializeManagedObject()
        {
            if (this._managedObject != null)
            {
                return;
            }
            IVimHost host = this.VcService.GetHost(this.Name, false);

            if (host == null)
            {
                return;
            }
            this._managedObject = host.ManagedObject;
        }
Esempio n. 11
0
        private void Create()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _adapter = _factory.Create <IVsAdapter>();
            _adapter.Setup(x => x.IsWatchWindowView(It.IsAny <ITextView>())).Returns(false);
            _undoManagerProvider            = _factory.Create <ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService   = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();
            _statusBar = _factory.Create <StatusBar>();
            _shell     = _factory.Create <IVsUIShell4>();
            _dte       = _factory.Create <_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create <ITextManager>();
            _textManager.Setup(x => x.GetDocumentTextViews(DocumentLoad.RespectLazy)).Returns(new List <ITextView>());
            _vimApplicationSettings = _factory.Create <IVimApplicationSettings>(MockBehavior.Loose);
            _extensionAdapterBroker = _factory.Create <IExtensionAdapterBroker>(MockBehavior.Loose);

            var  vsMonitorSelection = _factory.Create <IVsMonitorSelection>();
            uint cookie             = 42;

            vsMonitorSelection.Setup(x => x.AdviseSelectionEvents(It.IsAny <IVsSelectionEvents>(), out cookie)).Returns(VSConstants.S_OK);

            var telemetryProvider = _factory.Create <ITelemetryProvider>(MockBehavior.Loose);

            telemetryProvider.Setup(x => x.GetOrCreate(_vimApplicationSettings.Object, _dte.Object)).Returns(_factory.Create <ITelemetry>(MockBehavior.Loose).Object);

            var sp = _factory.Create <SVsServiceProvider>();

            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_shell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create <IVsExtensibility>().Object);
            sp.Setup(x => x.GetService(typeof(SVsShellMonitorSelection))).Returns(vsMonitorSelection.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create <ITextBufferFactoryService>().Object,
                _factory.Create <ITextEditorFactoryService>().Object,
                _factory.Create <ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                _factory.Create <ISmartIndentationService>().Object,
                _textManager.Object,
                _factory.Create <ISharedServiceFactory>(MockBehavior.Loose).Object,
                _vimApplicationSettings.Object,
                _extensionAdapterBroker.Object,
                sp.Object,
                telemetryProvider.Object);
            _host = _hostRaw;
        }
Esempio n. 12
0
 public HostFactory(
     IVim vim,
     ITextEditorFactoryService editorFactoryService,
     IKeyBindingService keyBindingService,
     SVsServiceProvider serviceProvider,
     IVsEditorAdaptersFactoryService adaptersFactory,
     IVimHost host,
     IFileSystem fileSystem)
 {
     _vim = vim;
     _keyBindingService = keyBindingService;
     _editorFactoryService = editorFactoryService;
     _serviceProvider = serviceProvider;
     _adaptersFactory = adaptersFactory;
     _host = host;
     _fileSystem = fileSystem;
 }
Esempio n. 13
0
        internal static ICommonOperations CreateCommonOperations(
            ITextView textView,
            IVimLocalSettings localSettings,
            IOutliningManager outlining            = null,
            IStatusUtil statusUtil                 = null,
            ISearchService searchService           = null,
            IUndoRedoOperations undoRedoOperations = null,
            IVimData vimData = null,
            IVimHost vimHost = null,
            ITextStructureNavigator navigator = null,
            IClipboardDevice clipboardDevice  = null,
            IFoldManager foldManager          = null)
        {
            var editorOperations = EditorUtil.GetOperations(textView);
            var editorOptions    = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
            var jumpList         = new JumpList(new TrackingLineColumnService());
            var keyMap           = new KeyMap();

            foldManager        = foldManager ?? new FoldManager(textView.TextBuffer);
            statusUtil         = statusUtil ?? new StatusUtil();
            searchService      = searchService ?? CreateSearchService(localSettings.GlobalSettings);
            undoRedoOperations = undoRedoOperations ??
                                 new UndoRedoOperations(statusUtil, FSharpOption <ITextUndoHistory> .None, editorOperations);
            vimData         = vimData ?? new VimData();
            vimHost         = vimHost ?? new MockVimHost();
            navigator       = navigator ?? CreateTextStructureNavigator(textView.TextBuffer);
            clipboardDevice = clipboardDevice ?? new MockClipboardDevice();
            var operationsData = new OperationsData(
                editorOperations,
                editorOptions,
                foldManager,
                jumpList,
                keyMap,
                localSettings,
                outlining != null ? FSharpOption.Create(outlining) : FSharpOption <IOutliningManager> .None,
                CreateRegisterMap(clipboardDevice),
                searchService,
                statusUtil,
                textView,
                undoRedoOperations,
                vimData,
                vimHost,
                navigator);

            return(new CommonOperations(operationsData));
        }
Esempio n. 14
0
 internal static ICommonOperations CreateCommonOperations(
     ITextView textView,
     IVimLocalSettings localSettings,
     IOutliningManager outlining = null,
     IStatusUtil statusUtil = null,
     ISearchService searchService = null,
     IUndoRedoOperations undoRedoOperations = null,
     IVimData vimData = null,
     IVimHost vimHost = null,
     ITextStructureNavigator navigator = null,
     IClipboardDevice clipboardDevice = null,
     IFoldManager foldManager = null)
 {
     var editorOperations = EditorUtil.GetOperations(textView);
     var editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
     var jumpList = new JumpList(new TrackingLineColumnService());
     var keyMap = new KeyMap();
     foldManager = foldManager ?? new FoldManager(textView.TextBuffer);
     statusUtil = statusUtil ?? new StatusUtil();
     searchService = searchService ?? CreateSearchService(localSettings.GlobalSettings);
     undoRedoOperations = undoRedoOperations ??
                          new UndoRedoOperations(statusUtil, FSharpOption<ITextUndoHistory>.None);
     vimData = vimData ?? new VimData();
     vimHost = vimHost ?? new MockVimHost();
     navigator = navigator ?? CreateTextStructureNavigator(textView.TextBuffer);
     clipboardDevice = clipboardDevice ?? new MockClipboardDevice();
     var operationsData = new OperationsData(
         editorOperations,
         editorOptions,
         foldManager,
         jumpList,
         keyMap,
         localSettings,
         outlining != null ? FSharpOption.Create(outlining) : FSharpOption<IOutliningManager>.None,
         CreateRegisterMap(clipboardDevice),
         searchService,
         EditorUtil.FactoryService.SmartIndentationService,
         statusUtil,
         textView,
         undoRedoOperations,
         vimData,
         vimHost,
         navigator);
     return new CommonOperations(operationsData);
 }
Esempio n. 15
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap          = null,
            IMarkMap map                      = null,
            IVimGlobalSettings globalSettings = null,
            IVimGlobalAbbreviationMap globalAbbreviationMap = null,
            IVimGlobalKeyMap globalKeyMap = null,
            IVimHost host = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData             = null,
            IMacroRecorder macroRecorder = null,
            ISearchService searchService = null,
            Dictionary <string, VariableValue> variableMap = null,
            MockRepository factory = null)
        {
            factory               = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap           = registerMap ?? CreateRegisterMap().Object;
            map                   = map ?? new MarkMap(new BufferTrackingService());
            globalSettings        = globalSettings ?? new GlobalSettings();
            host                  = host ?? new MockVimHost();
            variableMap           = variableMap ?? new Dictionary <string, VariableValue>();
            globalKeyMap          = globalKeyMap ?? new GlobalKeyMap(variableMap);
            macroRecorder         = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService         = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice        = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice           = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData               = vimData ?? VimUtil.CreateVimData();
            globalAbbreviationMap = globalAbbreviationMap ?? new GlobalAbbreviationMap();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.GlobalSettings).Returns(globalSettings);
            mock.SetupGet(x => x.GlobalAbbreviationMap).Returns(globalAbbreviationMap);
            mock.SetupGet(x => x.GlobalKeyMap).Returns(globalKeyMap);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            mock.SetupGet(x => x.VariableMap).Returns(variableMap);
            return(mock);
        }
Esempio n. 16
0
        private void Create()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _adapter = _factory.Create<IVsAdapter>();
            _adapter.Setup(x => x.IsWatchWindowView(It.IsAny<ITextView>())).Returns(false);
            _undoManagerProvider = _factory.Create<ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>();
            _statusBar = _factory.Create<StatusBar>();
            _shell = _factory.Create<IVsUIShell4>();
            _dte = _factory.Create<_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create<ITextManager>();
            _textManager.Setup(x => x.GetDocumentTextViews(DocumentLoad.RespectLazy)).Returns(new List<ITextView>());
            _vimApplicationSettings = _factory.Create<IVimApplicationSettings>(MockBehavior.Loose);
            _extensionAdapterBroker = _factory.Create<IExtensionAdapterBroker>(MockBehavior.Loose);

            var vsMonitorSelection = _factory.Create<IVsMonitorSelection>();
            uint cookie = 42;
            vsMonitorSelection.Setup(x => x.AdviseSelectionEvents(It.IsAny<IVsSelectionEvents>(), out cookie)).Returns(VSConstants.S_OK);

            var sp = _factory.Create<SVsServiceProvider>();
            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_shell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create<IVsExtensibility>().Object);
            sp.Setup(x => x.GetService(typeof(SVsShellMonitorSelection))).Returns(vsMonitorSelection.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create<ITextBufferFactoryService>().Object,
                _factory.Create<ITextEditorFactoryService>().Object,
                _factory.Create<ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                _factory.Create<ISmartIndentationService>().Object,
                _textManager.Object,
                _factory.Create<ISharedServiceFactory>(MockBehavior.Loose).Object,
                _vimApplicationSettings.Object,
                _extensionAdapterBroker.Object,
                sp.Object);
            _host = _hostRaw;
        }
Esempio n. 17
0
        public bool IsReadOnly(IVimHost vimHost)
        {
            bool flag = false;
            Dictionary <string, object> properties = this.GetProperties(new string[1] {
                "host"
            });

            if (properties.ContainsKey("host"))
            {
                foreach (DatastoreHostMount datastoreHostMount in (DatastoreHostMount[])properties["host"])
                {
                    if (datastoreHostMount.key.Value == vimHost.ManagedObject.Value && string.Compare(datastoreHostMount.mountInfo.accessMode, "readOnly", true) == 0)
                    {
                        flag = true;
                        break;
                    }
                }
            }
            return(flag);
        }
 public void Invoke(IVimVm vm)
 {
     this._Vm = vm;
     this._Logger.FormatInformation("Adding disk to the vm {0}", (object)this._Vm.Name);
     this._Context.SetLowLevelState("ConfiguringVm");
     this._ESXHost  = this._GetESXHostVim();
     this._HelperVm = this._GetHelperVm();
     this._HelperSCSIControllers = this._HelperVm.GetScsiControllersInfo();
     this._Logger.Information("Setting up VMDK file information");
     this._AssignControllersToVolumes();
     VmDiskInfo[] vmDiskInfoArray = this._BuildDiskList(this._Context.JobInfoWrapper.VolumePersistedState);
     if (vmDiskInfoArray.Length == 0)
     {
         throw new OculiServiceException(0, "There are no disks to create");
     }
     vmDiskInfoArray[0].SizeMB = Math.Max(vmDiskInfoArray[0].SizeMB, 2060L);
     this._CheckStopping();
     this._CreateAnyAdditionalSCSIControllers(this._Vm, vmDiskInfoArray);
     this._AddDisksTo(this._Vm, vmDiskInfoArray);
     AddDisksToExistingVmESX._VerifyDisksAllAdded(this._Vm, vmDiskInfoArray);
     this._Logger.Information("All disks added");
 }
Esempio n. 19
0
        private void Create()
        {
            _factory                        = new MockRepository(MockBehavior.Strict);
            _adapter                        = _factory.Create <IVsAdapter>();
            _undoManagerProvider            = _factory.Create <ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService   = _factory.Create <IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create <IEditorOperationsFactoryService>();
            _statusBar                      = _factory.Create <StatusBar>();
            _shell = _factory.Create <IVsUIShell4>();
            _dte   = _factory.Create <_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create <ITextManager>();
            _textManager.SetupGet(x => x.TextViews).Returns(new List <ITextView>());

            var  vsMonitorSelection = _factory.Create <IVsMonitorSelection>();
            uint cookie             = 42;

            vsMonitorSelection.Setup(x => x.AdviseSelectionEvents(It.IsAny <IVsSelectionEvents>(), out cookie)).Returns(VSConstants.S_OK);

            var sp = _factory.Create <SVsServiceProvider>();

            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_shell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create <IVsExtensibility>().Object);
            sp.Setup(x => x.GetService(typeof(SVsShellMonitorSelection))).Returns(vsMonitorSelection.Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create <ITextBufferFactoryService>().Object,
                _factory.Create <ITextEditorFactoryService>().Object,
                _factory.Create <ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                WordUtilFactory,
                _textManager.Object,
                _factory.Create <ISharedServiceFactory>(MockBehavior.Loose).Object,
                sp.Object);
            _host = _hostRaw;
        }
Esempio n. 20
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     IMarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null,
     IVimData vimData = null,
     IMacroRecorder macroRecorder = null,
     ISearchService searchService = null,
     Dictionary<string, VariableValue> variableMap = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new BufferTrackingService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap(settings, new Dictionary<string, VariableValue>()));
     macroRecorder = macroRecorder ?? CreateMacroRecorder(factory: factory).Object;
     searchService = searchService ?? factory.Create<ISearchService>().Object;
     keyboardDevice = keyboardDevice ?? (factory.Create<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (factory.Create<IMouseDevice>(MockBehavior.Loose)).Object;
     vimData = vimData ?? VimUtil.CreateVimData();
     variableMap = variableMap ?? new Dictionary<string, VariableValue>();
     var mock = factory.Create<IVim>(MockBehavior.Strict);
     mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
     mock.SetupGet(x => x.MarkMap).Returns(map);
     mock.SetupGet(x => x.GlobalSettings).Returns(settings);
     mock.SetupGet(x => x.VimHost).Returns(host);
     mock.SetupGet(x => x.KeyMap).Returns(keyMap);
     mock.SetupGet(x => x.VimData).Returns(vimData);
     mock.SetupGet(x => x.MacroRecorder).Returns(macroRecorder);
     mock.SetupGet(x => x.SearchService).Returns(searchService);
     mock.SetupGet(x => x.VariableMap).Returns(variableMap);
     return mock;
 }
Esempio n. 21
0
        public void Invoke()
        {
            this._Context.Logger.Information("Creating and configuring the replica vm.");
            this._Context.SetHighAndLowLevelState("PROVISIONING", "ConfiguringVm");
            if (this._Context.JobInfoWrapper.SourceVolumes.Length == 0)
            {
                throw new OculiServiceServiceException(0, "There are no source volumes specified");
            }
            this._ESXHost  = this._Context.ESXHost.HelperESXHost();
            this._HelperVm = this._Context.ESXHost.HelperVm();
            this._HelperSCSIControllers = this._HelperVm.GetScsiControllersInfo();
            this._ValidateHelperForJob();
            this._CheckStopping();
            this._CreateVmName();
            this._CheckStopping();
            IVimVm vm = this._CreateVm();

            this._Context.Logger.Verbose(" vm \"" + this._Context.JobInfoWrapper.VmName + "\" created");
            this._Context.JobInfoWrapper.VmUuid = new Guid(vm.Uuid);
            this._Context.Logger.Verbose("Saving the  VM's GUID: " + vm.Uuid);
            this._Context.SetLowLevelState("ConfiguringVm");
            this._CreateNewDisks(vm);
            this._Context.Logger.Information("Creation and configuration of replica vm is complete.");
        }
Esempio n. 22
0
        public static Mock <IVim> CreateVim(
            IRegisterMap registerMap       = null,
            IMarkMap map                   = null,
            IVimGlobalSettings settings    = null,
            IVimHost host                  = null,
            IKeyMap keyMap                 = null,
            IKeyboardDevice keyboardDevice = null,
            IMouseDevice mouseDevice       = null,
            IVimData vimData               = null,
            IMacroRecorder recorder        = null,
            ISearchService searchService   = null,
            MockRepository factory         = null)
        {
            factory        = factory ?? new MockRepository(MockBehavior.Strict);
            registerMap    = registerMap ?? CreateRegisterMap().Object;
            map            = map ?? new MarkMap(new TrackingLineColumnService());
            settings       = settings ?? new GlobalSettings();
            host           = host ?? new MockVimHost();
            keyMap         = keyMap ?? (new KeyMap());
            recorder       = recorder ?? CreateMacroRecorder(factory: factory).Object;
            searchService  = searchService ?? factory.Create <ISearchService>().Object;
            keyboardDevice = keyboardDevice ?? (factory.Create <IKeyboardDevice>(MockBehavior.Loose)).Object;
            mouseDevice    = mouseDevice ?? (factory.Create <IMouseDevice>(MockBehavior.Loose)).Object;
            vimData        = vimData ?? new VimData();
            var mock = factory.Create <IVim>(MockBehavior.Strict);

            mock.SetupGet(x => x.RegisterMap).Returns(registerMap);
            mock.SetupGet(x => x.MarkMap).Returns(map);
            mock.SetupGet(x => x.Settings).Returns(settings);
            mock.SetupGet(x => x.VimHost).Returns(host);
            mock.SetupGet(x => x.KeyMap).Returns(keyMap);
            mock.SetupGet(x => x.VimData).Returns(vimData);
            mock.SetupGet(x => x.MacroRecorder).Returns(recorder);
            mock.SetupGet(x => x.SearchService).Returns(searchService);
            return(mock);
        }
Esempio n. 23
0
        public IVimHost[] GetHosts()
        {
            Dictionary <string, object> properties = this.GetProperties(new string[1] {
                "host"
            });
            List <IVimHost> vimHostList = new List <IVimHost>();

            if (properties.ContainsKey("host"))
            {
                foreach (DatastoreHostMount datastoreHostMount in (DatastoreHostMount[])properties["host"])
                {
                    try
                    {
                        IVimHost vimHost = (IVimHost) new Host(this.VcService, datastoreHostMount.key);
                        vimHost.GetCommonProperties();
                        vimHostList.Add(vimHost);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
            return(vimHostList.ToArray());
        }
 internal DirectoryKeyProcessorProvider(IDirectoryUtil directoryUtil, IVimHost vimHost)
 {
     _directoryUtil = directoryUtil;
     _vimHost       = vimHost;
 }
 internal DirectoryKeyProcessor(string directoryPath, IVimHost vimHost, ITextView textView)
 {
     _directoryPath = directoryPath;
     _vimHost       = vimHost;
     _textView      = textView;
 }
Esempio n. 26
0
 public ModeNormal(IVimHost host)
 {
     this.Host = host;
 }
Esempio n. 27
0
 public static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null,
     IChangeTracker changeTracker = null,
     IKeyboardDevice keyboardDevice = null,
     IMouseDevice mouseDevice = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new MockVimHost();
     keyMap = keyMap ?? (new KeyMap());
     keyboardDevice = keyboardDevice ?? (new Mock<IKeyboardDevice>(MockBehavior.Loose)).Object;
     mouseDevice = mouseDevice ?? (new Mock<IMouseDevice>(MockBehavior.Loose)).Object;
     changeTracker = changeTracker ?? new ChangeTracker(new TextChangeTrackerFactory(keyboardDevice, mouseDevice));
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.VimHost).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     mock.Setup(x => x.ChangeTracker).Returns(changeTracker);
     return mock;
 }
Esempio n. 28
0
 internal DirectoryKeyProcessor(string directoryPath, IVimHost vimHost, ITextView textView)
 {
     _directoryPath = directoryPath;
     _vimHost = vimHost;
     _textView = textView;
 }
Esempio n. 29
0
 internal OperationsImpl(ITextView view, IEditorOperations opts, IVimHost host, IJumpList jumpList)
     : base(view, opts, host, jumpList)
 {
 }
Esempio n. 30
0
 public EditionRedo(IVimHost host, int repeat)
     : base(host, repeat)
 {
 }
Esempio n. 31
0
 public EditionDeleteRange(IVimHost host, int repeat, IVimMotion motion)
     : base(host, repeat)
 {
     this.Motion = motion;
 }
Esempio n. 32
0
 public abstract bool Apply(IVimHost host);
Esempio n. 33
0
 private void Create()
 {
     _undoManagerProvider = new Mock<ITextBufferUndoManagerProvider>(MockBehavior.Strict);
     _editorAdaptersFactoryService = new Mock<IVsEditorAdaptersFactoryService>(MockBehavior.Strict);
     _hostRaw = new VsVimHost(_undoManagerProvider.Object, _editorAdaptersFactoryService.Object);
     _host = _hostRaw;
 }
Esempio n. 34
0
 internal static UndoRedoOperations CreateUndoRedoOperations(IStatusUtil statusUtil = null, IVimHost vimHost = null)
 {
     statusUtil = statusUtil ?? new StatusUtil();
     vimHost    = vimHost ?? new MockVimHost();
     return(new UndoRedoOperations(vimHost, statusUtil, FSharpOption <ITextUndoHistory> .None, null));
 }
Esempio n. 35
0
 internal static Mock<IVim> CreateVim(
     IRegisterMap registerMap = null,
     MarkMap map = null,
     IVimGlobalSettings settings = null,
     IVimHost host = null,
     IKeyMap keyMap = null)
 {
     registerMap = registerMap ?? CreateRegisterMap().Object;
     map = map ?? new MarkMap(new TrackingLineColumnService());
     settings = settings ?? new GlobalSettings();
     host = host ?? new FakeVimHost();
     keyMap = keyMap ?? (new KeyMap());
     var mock = new Mock<IVim>(MockBehavior.Strict);
     mock.Setup(x => x.RegisterMap).Returns(registerMap);
     mock.Setup(x => x.MarkMap).Returns(map);
     mock.Setup(x => x.Settings).Returns(settings);
     mock.Setup(x => x.Host).Returns(host);
     mock.Setup(x => x.KeyMap).Returns(keyMap);
     return mock;
 }
Esempio n. 36
0
 public MotionMoveToNextWord(IVimHost host, int repeat)
     : base(host, repeat)
 {
 }
Esempio n. 37
0
 public void TearDown()
 {
     _statusBar = null;
     _dte = null;
     _host = null;
     _hostRaw = null;
 }
Esempio n. 38
0
        private void Create()
        {
            _undoManagerProvider = new Mock<ITextBufferUndoManagerProvider>(MockBehavior.Strict);
            _editorAdaptersFactoryService = new Mock<IVsEditorAdaptersFactoryService>(MockBehavior.Strict);
            _statusBar = new Mock<StatusBar>(MockBehavior.Strict);
            _dte = new Mock<_DTE>(MockBehavior.Strict);
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = new Mock<IVsTextManager>(MockBehavior.Strict);

            var sp = new Mock<SVsServiceProvider>(MockBehavior.Strict);
            sp.Setup(x => x.GetService(typeof(SVsTextManager))).Returns(_textManager.Object);
            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            _hostRaw = new VsVimHost(_undoManagerProvider.Object, _editorAdaptersFactoryService.Object, sp.Object);
            _host = _hostRaw;
        }
 internal DirectoryKeyProcessorProvider(IDirectoryUtil directoryUtil, IVimHost vimHost)
 {
     _directoryUtil = directoryUtil;
     _vimHost = vimHost;
 }
Esempio n. 40
0
        private void Create()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _adapter = _factory.Create<IVsAdapter>();
            _undoManagerProvider = _factory.Create<ITextBufferUndoManagerProvider>();
            _editorAdaptersFactoryService = _factory.Create<IVsEditorAdaptersFactoryService>();
            _editorOperationsFactoryService = _factory.Create<IEditorOperationsFactoryService>();
            _statusBar = _factory.Create<StatusBar>();
            _shell = _factory.Create<IVsUIShell4>();
            _dte = _factory.Create<_DTE>();
            _dte.SetupGet(x => x.StatusBar).Returns(_statusBar.Object);
            _textManager = _factory.Create<ITextManager>();

            var sp = _factory.Create<SVsServiceProvider>();
            sp.Setup(x => x.GetService(typeof(_DTE))).Returns(_dte.Object);
            sp.Setup(x => x.GetService(typeof(SVsUIShell))).Returns(_shell.Object);
            sp.Setup(x => x.GetService(typeof(IVsExtensibility))).Returns(_factory.Create<IVsExtensibility>().Object);
            _hostRaw = new VsVimHost(
                _adapter.Object,
                _factory.Create<ITextBufferFactoryService>().Object,
                _factory.Create<ITextEditorFactoryService>().Object,
                _factory.Create<ITextDocumentFactoryService>().Object,
                _undoManagerProvider.Object,
                _editorAdaptersFactoryService.Object,
                _editorOperationsFactoryService.Object,
                WordUtilFactory,
                _textManager.Object,
                _factory.Create<ISharedServiceFactory>(MockBehavior.Loose).Object,
                sp.Object);
            _host = _hostRaw;
        }
Esempio n. 41
0
 public void Create2(
     ModeKind kind=ModeKind.VisualCharacter,
     IVimHost host= null,
     params string[] lines)
 {
     _buffer = EditorUtil.CreateBuffer(lines);
     _caret = new Mock<ITextCaret>(MockBehavior.Strict);
     _view = new Mock<IWpfTextView>(MockBehavior.Strict);
     _selection = new Mock<ITextSelection>(MockBehavior.Strict);
     _view.SetupGet(x => x.Caret).Returns(_caret.Object);
     _view.SetupGet(x => x.Selection).Returns(_selection.Object);
     _view.SetupGet(x => x.TextBuffer).Returns(_buffer);
     _view.SetupGet(x => x.TextSnapshot).Returns(() => _buffer.CurrentSnapshot);
     _map = new RegisterMap();
     _editOpts = new Mock<IEditorOperations>(MockBehavior.Strict);
     _tracker = new Mock<ISelectionTracker>(MockBehavior.Strict);
     _tracker.Setup(x => x.Start());
     _operations = new Mock<IOperations>(MockBehavior.Strict);
     _operations.SetupGet(x => x.SelectionTracker).Returns(_tracker.Object);
     host = host ?? new FakeVimHost();
     _bufferData = MockObjectFactory.CreateVimBuffer(
         _view.Object,
         "test",
         MockObjectFactory.CreateVim(_map,host:host).Object,
         _editOpts.Object);
     _modeRaw = new Vim.Modes.Visual.VisualMode(Tuple.Create<IVimBuffer, IOperations, ModeKind>(_bufferData.Object, _operations.Object, kind));
     _mode = _modeRaw;
     _mode.OnEnter();
 }
Esempio n. 42
0
 internal OperationsImpl(ITextView view, IEditorOperations opts, IOutliningManager outlining, IVimHost host, IJumpList jumpList, IVimLocalSettings settings, IUndoRedoOperations undoRedoOpts)
     : base(view, opts, outlining, host, jumpList, settings, undoRedoOpts)
 {
 }
Esempio n. 43
0
 public VsKeyProcessor(IVimHost host)
 {
     _host = host;
 }