private StubTabContent CreateClosableTab() { var tab = new StubTabContent(); var close = new StubCommand { CanExecute = arg => true }; close.Execute = arg => tab.Closed.Invoke(tab, EventArgs.Empty); tab.Close = close; return(tab); }
public void ActiveTabCanTellEditorToSwitch() { var tab0 = new StubTabContent(); var tab1 = new StubTabContent(); editor.Add(tab0); editor.Add(tab1); tab1.RequestTabChange.Invoke(tab1, tab0); // tab 1 is requesting that the editor switch to tab 0 Assert.Equal(0, editor.SelectedIndex); }
public void NonActiveTabSwitchesAreIgnored() { var tab0 = new StubTabContent(); var tab1 = new StubTabContent(); editor.Add(tab0); editor.Add(tab1); tab1.RequestTabChange.Invoke(tab0, tab0); // tab 0 is trying to force itself to be focused Assert.Equal(1, editor.SelectedIndex); }
public void ShowingGotoClearsErrors() { var tab = new StubTabContent(); editor.Add(tab); tab.OnError.Invoke(tab, "Some Message"); editor.GotoViewModel.ShowGoto.Execute(true); Assert.True(editor.GotoViewModel.ControlVisible); Assert.False(editor.ShowError); }
public void EditorShowsErrors() { var tab = new StubTabContent(); editor.Add(tab); var clearErrorChangedNotifications = 0; editor.ClearError.CanExecuteChanged += (sender, e) => clearErrorChangedNotifications += 1; tab.OnError.Invoke(tab, "Some Message"); Assert.True(editor.ShowError); Assert.Equal("Some Message", editor.ErrorMessage); Assert.Equal(1, clearErrorChangedNotifications); }
public void EditorCanClearErrors() { var tab = new StubTabContent(); editor.Add(tab); var clearErrorChangedNotifications = 0; editor.ClearError.CanExecuteChanged += (sender, e) => clearErrorChangedNotifications += 1; tab.OnError.Invoke(tab, "Some Message"); editor.ClearError.Execute(); Assert.False(editor.ShowError); Assert.Equal(editor.ErrorMessage, string.Empty); Assert.Equal(2, clearErrorChangedNotifications); }
public void SaveAllChangesWhenCurrentFileChanges() { int count = 0; var save = new StubCommand(); var tab = new StubTabContent { Save = save }; editor.Add(tab); editor.SaveAll.CanExecuteChanged += (sender, e) => count++; save.CanExecute = arg => true; save.CanExecuteChanged.Invoke(save, EventArgs.Empty); Assert.Equal(1, count); }
public void EditorNotifiesWhenUndoCanExecuteChange() { int count = 0; var undo = new StubCommand(); var tab = new StubTabContent { Undo = undo }; editor.Add(tab); editor.Undo.CanExecuteChanged += (sender, e) => count++; undo.CanExecute = arg => true; undo.CanExecuteChanged.Invoke(undo, EventArgs.Empty); Assert.Equal(1, count); }
public void TabGetsRefreshedWhenSwitchedIn() { int count = 0; var tab1 = new StubTabContent { Refresh = () => count++ }; var tab2 = new StubTabContent(); editor.Add(tab1); count = 0; tab1.RequestTabChange?.Invoke(tab1, tab2); editor.SelectedIndex = 0; Assert.Equal(1, count); }
public void EditorForwardsTabDelayedWork() { void SomeAction() { } Action work = null; var editor = new EditorViewModel(new StubFileSystem()); var tab = new StubTabContent(); editor.Add(tab); editor.RequestDelayedWork += (sender, e) => work = e; tab.RequestDelayedWork.Invoke(tab, SomeAction); Assert.Equal(SomeAction, work); }
public void EditorNotifiesCanExecuteChangedOnTabChange(string commandName) { int count = 0; var command = (ICommand)editor.GetType().GetProperty(commandName).GetValue(editor); command.CanExecuteChanged += (sender, e) => count++; var tab = new StubTabContent(); tab.Close = new StubCommand { CanExecute = arg => true, Execute = arg => tab.Closed.Invoke(tab, EventArgs.Empty) }; editor.Add(tab); Assert.Equal(1, count); count = 0; editor.Close.Execute(); Assert.Equal(1, count); }