master
1using MbUnit.Framework;
2using Notepad.Infrastructure.Extensions;
3using Notepad.Presentation.Model.Menu.File.Commands;
4using Notepad.Presentation.Views.Menu.File;
5using Notepad.Tasks;
6using Rhino.Mocks;
7
8namespace Notepad.Presentation.Presenters.Menu.File {
9 public class SaveAsPresenterSpecs {}
10
11 [TestFixture]
12 public class when_initializing_the_save_as_presenter_ {
13 private MockRepository mockery;
14 private ISaveAsView view;
15 private ISaveAsPresenter sut;
16
17 [SetUp]
18 public void SetUp() {
19 mockery = new MockRepository();
20 view = mockery.DynamicMock<ISaveAsView>();
21
22 sut = CreateSUT();
23 }
24
25 private ISaveAsPresenter CreateSUT() {
26 return new SaveAsPresenter(view, null);
27 }
28
29 [Test]
30 public void should_initialize_the_view_with_itself() {
31 using (mockery.Record()) {
32 view.AttachTo(sut);
33 }
34
35 using (mockery.Playback()) {
36 sut.Initialize();
37 }
38 }
39 }
40
41 [TestFixture]
42 public class when_selecting_a_file_path_to_save_to_ {
43 private MockRepository mockery;
44 private ISaveCommand saveCommand;
45 private IDocumentTasks tasks;
46
47 [SetUp]
48 public void SetUp() {
49 mockery = new MockRepository();
50 tasks = mockery.DynamicMock<IDocumentTasks>();
51 }
52
53 [Test]
54 public void should_ask_the_active_document_to_save_the_path_specified() {
55 var pathToSaveFileTo = "some path";
56 using (mockery.Record()) {
57 tasks.SaveActiveDocumentTo(pathToSaveFileTo.AsAnAbsoluteFilePath());
58 }
59
60 using (mockery.Playback()) {
61 CreateSUT().SaveToFileAt(pathToSaveFileTo);
62 }
63 }
64
65 private ISaveAsPresenter CreateSUT() {
66 return new SaveAsPresenter(null, tasks);
67 }
68 }
69}