blob: 3220ae5de8da7516b3863137a579358df21f4994 (
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
|
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 ExitMenuItemSpecs {}
[TestFixture]
public class when_asking_the_exit_menu_item_for_its_name_ {
[Test]
public void should_return_the_correct_name() {
CreateSUT().Name().ShouldBeEqualTo("E&xit");
}
private IMenuItem CreateSUT() {
return new ExitMenuItem(null);
}
}
[TestFixture]
public class when_clicking_on_the_exit_menu_item_ {
private MockRepository mockery;
private IExitCommand exitCommand;
[SetUp]
public void SetUp() {
mockery = new MockRepository();
exitCommand = mockery.DynamicMock<IExitCommand>();
}
[Test]
public void should_execute_the_exit_command() {
using (mockery.Record()) {}
using (mockery.Playback()) {
CreateSUT().Click();
}
}
private IMenuItem CreateSUT() {
return new ExitMenuItem(exitCommand);
}
}
[TestFixture]
public class when_asking_the_exit_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 ExitMenuItem(null);
}
}
}
|