master
1using MbUnit.Framework;
2using Rhino.Mocks;
3
4namespace Notepad.Presentation.Core {
5 public class ApplicationControllerSpecs {}
6
7 [TestFixture]
8 public class when_the_application_controller_is_asked_to_run_a_presenter_ {
9 private MockRepository mockery;
10 private IPresenterRegistry presenterRegistry;
11
12 [SetUp]
13 public void SetUp() {
14 mockery = new MockRepository();
15 presenterRegistry = mockery.DynamicMock<IPresenterRegistry>();
16 }
17
18 [Test]
19 public void should_ask_the_registered_presenters_for_an_instance_of_the_presenter_to_run() {
20 var implementationOfThePresenter = mockery.DynamicMock<IPresenter>();
21 using (mockery.Record()) {
22 Expect
23 .Call(presenterRegistry.FindAnImplementationOf<IPresenter>())
24 .Return(implementationOfThePresenter)
25 .Repeat
26 .AtLeastOnce();
27 }
28
29 using (mockery.Playback()) {
30 CreateSUT().Run<IPresenter>();
31 }
32 }
33
34 [Test]
35 public void should_initialize_the_presenter_to_run() {
36 var presenterToInitialize = mockery.DynamicMock<IPresenter>();
37 using (mockery.Record()) {
38 SetupResult
39 .For(presenterRegistry.FindAnImplementationOf<IPresenter>())
40 .Return(presenterToInitialize);
41
42 presenterToInitialize.Initialize();
43 }
44
45 using (mockery.Playback()) {
46 CreateSUT().Run<IPresenter>();
47 }
48 }
49
50 private IApplicationController CreateSUT() {
51 return new ApplicationController(presenterRegistry);
52 }
53 }
54}