blob: 74d7663fd8a9cf2b44e6f5052dcf8a8004c69b37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
using MbUnit.Framework;
using Notepad.Presentation.Presenters.Commands;
using Notepad.Presentation.Presenters.Menu.Help;
using Notepad.Test.Extensions;
using Rhino.Mocks;
namespace Notepad.Presentation.Model.Menu.Help {
public class AboutMenuItemSpecs {}
[TestFixture]
public class when_asking_the_about_menu_item_for_its_name_ {
[Test]
public void should_return_the_correct_name() {
CreateSUT().Name().ShouldBeEqualTo(MenuItemNames.About);
}
private IMenuItem CreateSUT() {
return new AboutMenuItem(null);
}
}
[TestFixture]
public class when_clicking_on_the_about_menu_item_ {
private MockRepository mockery;
private IRunPresenterCommand<IAboutApplicationPresenter> displayAboutCommand;
[SetUp]
public void SetUp() {
mockery = new MockRepository();
displayAboutCommand = mockery.DynamicMock<IRunPresenterCommand<IAboutApplicationPresenter>>();
}
[Test]
public void should_execute_the_display_about_command() {
using (mockery.Record()) {}
using (mockery.Playback()) {
CreateSUT().Click();
}
}
private IMenuItem CreateSUT() {
return new AboutMenuItem(displayAboutCommand);
}
}
[TestFixture]
public class when_asking_the_about_menu_item_if_it_belongs_to_a_menu_that_it_does {
private MockRepository mockery;
private ISubMenu menuThatThisItemBelongsTo;
[SetUp]
public void SetUp() {
mockery = new MockRepository();
menuThatThisItemBelongsTo = mockery.DynamicMock<ISubMenu>();
SetupResult.For(menuThatThisItemBelongsTo.Name()).Return(MenuNames.Help);
}
[Test]
public void should_return_true() {
using (mockery.Record()) {}
using (mockery.Playback()) {
CreateSUT().BelongsTo(menuThatThisItemBelongsTo).ShouldBeEqualTo(true);
}
}
private IMenuItem CreateSUT() {
return new AboutMenuItem(null);
}
}
[TestFixture]
public class when_asking_the_about_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 AboutMenuItem(null);
}
}
}
|