Exemple #1
0
        private void ResetState()
        {
            Vim.MarkMap.Clear();

            Vim.VimData.SearchHistory.Reset();
            Vim.VimData.CommandHistory.Reset();
            Vim.VimData.LastCommand       = FSharpOption <StoredCommand> .None;
            Vim.VimData.LastCommandLine   = "";
            Vim.VimData.LastShellCommand  = FSharpOption <string> .None;
            Vim.VimData.LastTextInsert    = FSharpOption <string> .None;
            Vim.VimData.AutoCommands      = FSharpList <AutoCommand> .Empty;
            Vim.VimData.AutoCommandGroups = FSharpList <AutoCommandGroup> .Empty;

            Vim.KeyMap.ClearAll();
            Vim.KeyMap.IsZeroMappingEnabled = true;

            Vim.CloseAllVimBuffers();
            Vim.IsDisabled = false;

            // The majority of tests run without a VimRc file but a few do customize it for specific
            // test reasons.  Make sure it's consistent
            VimRcState = VimRcState.None;

            // Reset all of the global settings back to their default values.   Adds quite
            // a bit of sanity to the test bed
            foreach (var setting in Vim.GlobalSettings.Settings)
            {
                if (!setting.IsValueDefault && !setting.IsValueCalculated)
                {
                    Vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue);
                }
            }

            // Reset all of the register values to empty
            foreach (var name in Vim.RegisterMap.RegisterNames)
            {
                Vim.RegisterMap.GetRegister(name).UpdateValue("");
            }

            // Don't let recording persist across tests
            if (Vim.MacroRecorder.IsRecording)
            {
                Vim.MacroRecorder.StopRecording();
            }

            if (Vim.VimHost is MockVimHost vimHost)
            {
                vimHost.ShouldCreateVimBufferImpl = false;
                vimHost.Clear();
            }

            VariableMap.Clear();
            VimErrorDetector.Clear();
            TestableSynchronizationContext?.Dispose();
            TestableSynchronizationContext = null;
        }
            public void BadOrder()
            {
                Create(HistoryKind.Basic);

                var transaction1 = _undoRedoOperations.CreateUndoTransaction("test1");
                var transaction2 = _undoRedoOperations.CreateUndoTransaction("test2");

                Assert.Equal(2, _undoRedoOperationsRaw.NormalUndoTransactionStack.Count);

                _statusUtil.Setup(x => x.OnError(Resources.Undo_ChainOrderErrorNormal)).Verifiable();
                transaction1.Complete();
                Assert.Equal(0, _undoRedoOperationsRaw.NormalUndoTransactionStack.Count);
                _statusUtil.Verify();

                // We are closing transactions out of order.  This is absolutely an error and would normally be
                // picked up by the error detector and hence failing our test.  In this case the error is expected
                VimErrorDetector.Clear();
            }