public void AddMarkerReallyDoesAddNewMarker() { var markers = GetTestMarkers(); var newMarkerText = "Hi, guys:"; var newMarkerPriority = TodoPriority.High; var addView = new Mock <IAddTodoMarkerView>(); addView.SetupProperty(a => a.MarkerText, newMarkerText); addView.SetupProperty(a => a.MarkerPriority, newMarkerPriority); addView.SetupProperty(a => a.TodoMarkers, markers); var view = new Mock <ITodoSettingsView>(); view.SetupProperty(v => v.TodoMarkers, new BindingList <ToDoMarker>(markers)); // Shut up R#, I need that to process the event // ReSharper disable once UnusedVariable var presenter = new TodoSettingPresenter(view.Object, addView.Object); addView.Raise(a => a.AddMarker += null, EventArgs.Empty); Assert.IsTrue(view.Object.TodoMarkers.Contains(new ToDoMarker(newMarkerText, newMarkerPriority))); }
public void ConstructorWorks() { //arrange Mock <ITodoSettingsView> view = new Mock <ITodoSettingsView>(); //act var controller = new TodoSettingPresenter(view.Object); //assert Assert.IsNotNull(controller); }
public void SaveDisabledAfterSelectionChange() { var markers = GetTestMarkers(); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); view.SelectedIndex = 2; Assert.IsFalse(view.SaveEnabled); }
public void SaveEnabledAfterPriorityChange() { var markers = GetTestMarkers(); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); view.ActiveMarkerPriority = TodoPriority.High; Assert.IsTrue(view.SaveEnabled); }
public void SaveEnabledAfterTextChange() { var markers = GetTestMarkers(); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); view.ActiveMarkerText = "SomeNewText"; Assert.IsTrue(view.SaveEnabled); }
public void SetActiveItemChangesActiveMarker() { //arrange var markers = GetTestMarkers(); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); //act controller.SetActiveItem(1); Assert.AreEqual(markers[1], controller.ActiveMarker); }
public void SetActiveItemChangesViewSelectedIndex() { //arrange var markers = GetTestMarkers(); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); //act controller.SetActiveItem(1); Assert.AreEqual(1, view.SelectedIndex); }
public void ViewTextIsNotNullOrEmptyAfterControllerConstruction() { //arrange var markers = new List <ToDoMarker>(); markers.Add(new ToDoMarker("Todo:", TodoPriority.Normal)); ITodoSettingsView view = new MockTodoSettingsView(markers); //act var controller = new TodoSettingPresenter(view); //assert Assert.AreEqual("Todo:", view.ActiveMarkerText); }
public void ViewTextMatchesAfterSelectionChange() { var markers = new List <ToDoMarker>(); markers.Add(new ToDoMarker("Todo:", TodoPriority.Normal)); markers.Add(new ToDoMarker("Note:", TodoPriority.Low)); ITodoSettingsView view = new MockTodoSettingsView(markers); var controller = new TodoSettingPresenter(view); //act controller.SetActiveItem(1); Assert.AreEqual("Note:", view.ActiveMarkerText); }
public void RemoveReallyDoesRemoveSelectedItem() { var markers = GetTestMarkers(); var view = new Mock <ITodoSettingsView>(); view.SetupProperty(v => v.TodoMarkers, new BindingList <ToDoMarker>(markers)); // Shut up R#, I need that to process the event // ReSharper disable once UnusedVariable var presenter = new TodoSettingPresenter(view.Object, new Mock <IAddTodoMarkerView>().Object); view.Raise(v => v.RemoveMarker += null, EventArgs.Empty); Assert.AreEqual(markers.Count - 1, view.Object.TodoMarkers.Count); }
public void AddReallyDoesDisplayAddMarkerWindow() { var markers = GetTestMarkers(); var addView = new Mock <IAddTodoMarkerView>(); var view = new Mock <ITodoSettingsView>(); view.SetupProperty(v => v.TodoMarkers, new BindingList <ToDoMarker>(markers)); // Shut up R#, I need that to process the event // ReSharper disable once UnusedVariable var presenter = new TodoSettingPresenter(view.Object, addView.Object); view.Raise(v => v.AddMarker += null, EventArgs.Empty); addView.Verify(a => a.Show(), Times.Once()); }
public void AddMarkerHidesOnCancel() { var markers = GetTestMarkers(); var addView = new Mock <IAddTodoMarkerView>(); addView.SetupProperty(a => a.MarkerPriority, TodoPriority.Low); addView.SetupProperty(a => a.MarkerText, "new marker"); var view = new Mock <ITodoSettingsView>(); // Shut up R#, I need that to process the event // ReSharper disable once UnusedVariable var presenter = new TodoSettingPresenter(view.Object, addView.Object); addView.Raise(v => v.Cancel += null, EventArgs.Empty); addView.Verify(a => a.Hide(), Times.Once()); }
public void AddMarkerReallyDoesAllowExistingNames() { var markers = GetTestMarkers(); var addView = new Mock <IAddTodoMarkerView>(); addView.SetupProperty(a => a.MarkerText, "Hi, guys:"); addView.SetupProperty(a => a.IsValidMarker); var view = new Mock <ITodoSettingsView>(); view.SetupProperty(v => v.TodoMarkers, new BindingList <ToDoMarker>(markers)); // Shut up R#, I need that to process the event // ReSharper disable once UnusedVariable var presenter = new TodoSettingPresenter(view.Object, addView.Object); addView.Raise(a => a.TextChanged += null, EventArgs.Empty); Assert.IsTrue(addView.Object.IsValidMarker); }