예제 #1
0
        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)));
        }
예제 #2
0
        public void ConstructorWorks()
        {
            //arrange
            Mock <ITodoSettingsView> view = new Mock <ITodoSettingsView>();

            //act
            var controller = new TodoSettingPresenter(view.Object);

            //assert
            Assert.IsNotNull(controller);
        }
예제 #3
0
        public void SaveDisabledAfterSelectionChange()
        {
            var markers = GetTestMarkers();

            ITodoSettingsView view = new MockTodoSettingsView(markers);
            var controller         = new TodoSettingPresenter(view);

            view.SelectedIndex = 2;

            Assert.IsFalse(view.SaveEnabled);
        }
예제 #4
0
        public void SaveEnabledAfterPriorityChange()
        {
            var markers = GetTestMarkers();

            ITodoSettingsView view = new MockTodoSettingsView(markers);
            var controller         = new TodoSettingPresenter(view);

            view.ActiveMarkerPriority = TodoPriority.High;

            Assert.IsTrue(view.SaveEnabled);
        }
예제 #5
0
        public void SaveEnabledAfterTextChange()
        {
            var markers = GetTestMarkers();

            ITodoSettingsView view = new MockTodoSettingsView(markers);
            var controller         = new TodoSettingPresenter(view);

            view.ActiveMarkerText = "SomeNewText";

            Assert.IsTrue(view.SaveEnabled);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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());
        }
예제 #12
0
        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());
        }
예제 #13
0
        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);
        }