From 5ee1f55497a4e30322a56f133f897ecde1612967 Mon Sep 17 00:00:00 2001 From: mo Date: Sun, 4 Nov 2018 15:22:16 -0700 Subject: initial commit. --- .../Model/Menu/File/Commands/SaveCommandSpecs.cs | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 src/Notepad/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs (limited to 'src/Notepad/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs') diff --git a/src/Notepad/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs b/src/Notepad/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs new file mode 100644 index 0000000..7e4d827 --- /dev/null +++ b/src/Notepad/Presentation/Model/Menu/File/Commands/SaveCommandSpecs.cs @@ -0,0 +1,95 @@ +using MbUnit.Framework; +using Notepad.Presentation.Core; +using Notepad.Presentation.Presenters.Menu.File; +using Notepad.Tasks; +using Rhino.Mocks; + +namespace Notepad.Presentation.Model.Menu.File.Commands { + public class SaveCommandSpecs {} + + [TestFixture] + public class when_executing_the_save_command_and_a_file_path_to_save_to_has_not_been_specified_ { + private MockRepository mockery; + private IApplicationController applicationController; + private IDocumentTasks tasks; + + [SetUp] + public void SetUp() { + mockery = new MockRepository(); + applicationController = mockery.DynamicMock(); + tasks = mockery.DynamicMock(); + + SetupResult.For(tasks.HasAPathToSaveToBeenSpecified()).Return(false); + } + + [Test] + public void should_run_the_save_as_presenter() { + using (mockery.Record()) { + applicationController.Run(); + } + + using (mockery.Playback()) { + CreateSUT().Execute(); + } + } + + [Test] + public void should_not_save_the_active_document() { + using (mockery.Record()) { + tasks.SaveTheActiveDocument(); + LastCall.Repeat.Never(); + } + + using (mockery.Playback()) { + CreateSUT().Execute(); + } + } + + private ISaveCommand CreateSUT() { + return new SaveCommand(applicationController, tasks); + } + } + + [TestFixture] + public class when_executing_the_save_command_and_a_path_to_save_to_has_already_been_specified_ { + private MockRepository mockery; + private IApplicationController applicationController; + private IDocumentTasks tasks; + + [SetUp] + public void SetUp() { + mockery = new MockRepository(); + applicationController = mockery.DynamicMock(); + tasks = mockery.DynamicMock(); + + SetupResult.For(tasks.HasAPathToSaveToBeenSpecified()).Return(true); + } + + [Test] + public void should_not_run_the_save_as_presenter() { + using (mockery.Record()) { + applicationController.Run(); + LastCall.Repeat.Never(); + } + + using (mockery.Playback()) { + CreateSUT().Execute(); + } + } + + [Test] + public void should_save_the_active_document() { + using (mockery.Record()) { + tasks.SaveTheActiveDocument(); + } + + using (mockery.Playback()) { + CreateSUT().Execute(); + } + } + + private ISaveCommand CreateSUT() { + return new SaveCommand(applicationController, tasks); + } + } +} \ No newline at end of file -- cgit v1.2.3