master
1using MbUnit.Framework;
2using Notepad.Presentation.Model.Menu.File.Commands;
3using Notepad.Test.Extensions;
4using Rhino.Mocks;
5
6namespace Notepad.Presentation.Model.Menu.File {
7 public class ExitMenuItemSpecs {}
8
9 [TestFixture]
10 public class when_asking_the_exit_menu_item_for_its_name_ {
11 [Test]
12 public void should_return_the_correct_name() {
13 CreateSUT().Name().ShouldBeEqualTo("E&xit");
14 }
15
16 private IMenuItem CreateSUT() {
17 return new ExitMenuItem(null);
18 }
19 }
20
21 [TestFixture]
22 public class when_clicking_on_the_exit_menu_item_ {
23 private MockRepository mockery;
24 private IExitCommand exitCommand;
25
26 [SetUp]
27 public void SetUp() {
28 mockery = new MockRepository();
29 exitCommand = mockery.DynamicMock<IExitCommand>();
30 }
31
32 [Test]
33 public void should_execute_the_exit_command() {
34 using (mockery.Record()) {}
35
36 using (mockery.Playback()) {
37 CreateSUT().Click();
38 }
39 }
40
41 private IMenuItem CreateSUT() {
42 return new ExitMenuItem(exitCommand);
43 }
44 }
45
46 [TestFixture]
47 public class when_asking_the_exit_menu_item_if_it_belongs_to_a_menu_that_it_does {
48 private MockRepository mockery;
49 private ISubMenu fileMenu;
50
51 [SetUp]
52 public void SetUp() {
53 mockery = new MockRepository();
54 fileMenu = mockery.DynamicMock<ISubMenu>();
55
56 SetupResult.For(fileMenu.Name()).Return(MenuNames.File);
57 }
58
59 [Test]
60 public void should_return_true() {
61 using (mockery.Record()) {}
62
63 using (mockery.Playback()) {
64 CreateSUT().BelongsTo(fileMenu).ShouldBeEqualTo(true);
65 }
66 }
67
68 private IMenuItem CreateSUT() {
69 return new ExitMenuItem(null);
70 }
71 }
72}