Exemplo n.º 1
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            if (s_cachedVimEditorHost == null)
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                                          typeof(TestableClipboardDevice),
                                          typeof(TestableKeyboardDevice),
                                          typeof(TestableMouseDevice),
                                          typeof(global::Vim.UnitTest.Exports.VimHost),
                                          typeof(VimErrorDetector),
                                          typeof(DisplayWindowBrokerFactoryService),
                                          typeof(WordCompletionSessionFactoryService),
                                          typeof(AlternateKeyUtil),
                                          typeof(VimProtectedOperations),
                                          typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                s_cachedVimEditorHost = new VimEditorHost(compositionContainer);
            }

            return(s_cachedVimEditorHost);
        }
Exemplo n.º 2
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            var key = Thread.CurrentThread.ManagedThreadId;

            if (!s_cachedVimEditorHostMap.TryGetValue(key, out VimEditorHost host))
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                                          typeof(TestableClipboardDevice),
                                          typeof(TestableKeyboardDevice),
                                          typeof(TestableMouseDevice),
                                          typeof(global::Vim.UnitTest.Exports.VimHost),
                                          typeof(VimErrorDetector),
                                          typeof(DisplayWindowBrokerFactoryService),
                                          typeof(WordCompletionSessionFactoryService),
                                          typeof(AlternateKeyUtil),
                                          typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                host = new VimEditorHost(compositionContainer);
                s_cachedVimEditorHostMap[key] = host;
            }

            return(host);
        }
Exemplo n.º 3
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vimEditorHost       = GetOrCreateVimEditorHost();
            ClipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            Vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            Vim.AutoLoadVimRc = false;

            // Don't let the current directory leak into the tests
            Vim.VimData.CurrentDirectory = "";

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 4
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            _vimEditorHost = GetOrCreateVimEditorHost();
            ClipboardDevice.Text = String.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            Vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            Vim.AutoLoadVimRc = false;
            Vim.AutoLoadSessionData = false;

            // Don't let the current directory leak into the tests
            Vim.VimData.CurrentDirectory = "";

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;
        }
Exemplo n.º 5
0
        protected void Create(params string[] lines)
        {
            _textBuffer = VimEditorHost.CreateTextBuffer(lines);

            _asyncTaggerSource    = new TestableAsyncTaggerSource(_textBuffer);
            _asyncTagger          = new AsyncTagger <string, TextMarkerTag>(_asyncTaggerSource);
            _asyncTaggerInterface = _asyncTagger;
        }
Exemplo n.º 6
0
        protected VimTestBase()
        {
            // Parts of the core editor in Vs2012 depend on there being an Application.Current value else
            // they will throw a NullReferenceException.  Create one here to ensure the unit tests successfully
            // pass
            if (Application.Current == null)
            {
                new Application();
            }

            if (!StaTaskScheduler.DefaultSta.IsRunningInScheduler)
            {
                throw new Exception($"Need to apply {nameof(WpfFactAttribute)} to this test case");
            }

            if (SynchronizationContext.Current?.GetType() != typeof(DispatcherSynchronizationContext))
            {
                throw new Exception("Invalid synchronization context on test start");
            }

            _vimEditorHost       = GetOrCreateVimEditorHost();
            ClipboardDevice.Text = string.Empty;

            // One setting we do differ on for a default is 'timeout'.  We don't want them interfering
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            Vim.GlobalSettings.Timeout = false;

            // Turn off autoloading of digraphs for the vast majority of tests.
            Vim.AutoLoadDigraphs = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            Vim.AutoLoadVimRc       = false;
            Vim.AutoLoadSessionData = false;

            // Don't let the current directory leak into the tests
            Vim.VimData.CurrentDirectory = "";

            // Don't show trace information in the unit tests.  It really clutters the output in an
            // xUnit run
            VimTrace.TraceSwitch.Level = TraceLevel.Off;

            TestableSynchronizationContext = new TestableSynchronizationContext();
        }
Exemplo n.º 7
0
 public void Create(params string[] lines)
 {
     _textBuffer = VimEditorHost.CreateTextBuffer(lines);
 }
Exemplo n.º 8
0
        private static VimEditorHost GetOrCreateVimEditorHost()
        {
            if (s_cachedVimEditorHost == null)
            {
                var editorHostFactory = new EditorHostFactory();
                editorHostFactory.Add(new AssemblyCatalog(typeof(IVim).Assembly));

                // Other Exports needed to construct VsVim
                editorHostFactory.Add(new TypeCatalog(
                    typeof(TestableClipboardDevice),
                    typeof(TestableKeyboardDevice),
                    typeof(TestableMouseDevice),
                    typeof(global::Vim.UnitTest.Exports.VimHost),
                    typeof(VimErrorDetector),
                    typeof(DisplayWindowBrokerFactoryService),
                    typeof(WordCompletionSessionFactoryService),
                    typeof(AlternateKeyUtil),
                    typeof(VimProtectedOperations),
                    typeof(OutlinerTaggerProvider)));

                var compositionContainer = editorHostFactory.CreateCompositionContainer();
                s_cachedVimEditorHost = new VimEditorHost(compositionContainer);
            }

            return s_cachedVimEditorHost;
        }