summaryrefslogtreecommitdiff
path: root/src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs
diff options
context:
space:
mode:
authormo <mo.khan@gmail.com>2018-11-04 15:22:16 -0700
committermo <mo.khan@gmail.com>2018-11-04 15:22:16 -0700
commit5ee1f55497a4e30322a56f133f897ecde1612967 (patch)
treebf544e0879234c3623869627d8786776cb19b8e9 /src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs
initial commit.HEADmaster
Diffstat (limited to 'src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs')
-rw-r--r--src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs99
1 files changed, 99 insertions, 0 deletions
diff --git a/src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs b/src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs
new file mode 100644
index 0000000..071adf8
--- /dev/null
+++ b/src/Notepad/Presentation/Model/Menu/File/SaveMenuItemSpecs.cs
@@ -0,0 +1,99 @@
+using MbUnit.Framework;
+using Notepad.Presentation.Model.Menu.File.Commands;
+using Notepad.Test.Extensions;
+using Rhino.Mocks;
+
+namespace Notepad.Presentation.Model.Menu.File {
+ public class SaveMenuItemSpecs {}
+
+ [TestFixture]
+ public class when_asking_the_save_menu_item_for_its_name_ {
+ [Test]
+ public void should_return_the_correct_name() {
+ CreateSUT().Name().ShouldBeEqualTo("&Save");
+ }
+
+ private IMenuItem CreateSUT() {
+ return new SaveMenuItem(null);
+ }
+ }
+
+ [TestFixture]
+ public class when_clicking_on_the_save_menu_item_ {
+ private MockRepository mockery;
+ private ISaveCommand saveCommand;
+
+ [SetUp]
+ public void SetUp() {
+ mockery = new MockRepository();
+ saveCommand = mockery.DynamicMock<ISaveCommand>();
+ }
+
+ [Test]
+ public void should_execute_the_save_command() {
+ using (mockery.Record()) {}
+
+ using (mockery.Playback()) {
+ CreateSUT().Click();
+ }
+ }
+
+ private IMenuItem CreateSUT() {
+ return new SaveMenuItem(saveCommand);
+ }
+ }
+
+ [TestFixture]
+ public class when_asking_the_save_menu_item_if_it_belongs_to_a_menu_that_it_does {
+ private MockRepository mockery;
+ private ISubMenu fileMenu;
+
+ [SetUp]
+ public void SetUp() {
+ mockery = new MockRepository();
+ fileMenu = mockery.DynamicMock<ISubMenu>();
+
+ SetupResult.For(fileMenu.Name()).Return(MenuNames.File);
+ }
+
+ [Test]
+ public void should_return_true() {
+ using (mockery.Record()) {}
+
+ using (mockery.Playback()) {
+ CreateSUT().BelongsTo(fileMenu).ShouldBeEqualTo(true);
+ }
+ }
+
+ private IMenuItem CreateSUT() {
+ return new SaveMenuItem(null);
+ }
+ }
+
+ [TestFixture]
+ public class when_asking_the_save_menu_item_if_it_belongs_to_a_menu_item_that_it_does_not {
+ private MockRepository mockery;
+ private ISubMenu unknownMenu;
+
+ [SetUp]
+ public void SetUp() {
+ mockery = new MockRepository();
+ unknownMenu = mockery.DynamicMock<ISubMenu>();
+
+ SetupResult.For(unknownMenu.Name()).Return("blah");
+ }
+
+ [Test]
+ public void should_return_false() {
+ using (mockery.Record()) {}
+
+ using (mockery.Playback()) {
+ CreateSUT().BelongsTo(unknownMenu).ShouldBeEqualTo(false);
+ }
+ }
+
+ private IMenuItem CreateSUT() {
+ return new SaveMenuItem(null);
+ }
+ }
+} \ No newline at end of file