1
1
using Microsoft . VisualStudio . TestTools . UnitTesting ;
2
2
using System . Waf . UnitTesting . Mocks ;
3
3
using Test . Writer . Applications . Services ;
4
+ using Test . Writer . Applications . Views ;
5
+ using Waf . Writer . Applications . ViewModels ;
6
+ using Waf . Writer . Applications . Views ;
4
7
5
8
namespace Test . Writer . Presentation ;
6
9
@@ -23,4 +26,39 @@ public void OpenDocumentViaCommandLineIntegrationTest()
23
26
Assert . AreEqual ( MessageType . Error , messageService . MessageType ) ;
24
27
Assert . IsFalse ( string . IsNullOrEmpty ( messageService . Message ) ) ;
25
28
}
29
+
30
+ [ TestMethod ]
31
+ public void NewModifyAndCloseWithoutSave ( )
32
+ {
33
+ StartApp ( ) ;
34
+ var shellViewModel = Get < ShellViewModel > ( ) ;
35
+ var mainView = ( MockMainView ) shellViewModel . ContentView ;
36
+ Assert . AreEqual ( ContentViewState . StartViewVisible , mainView . ContentViewState ) ;
37
+ var mainViewModel = mainView . ViewModel ;
38
+
39
+ mainViewModel . FileService . NewCommand . Execute ( null ) ;
40
+ Assert . AreEqual ( ContentViewState . DocumentViewVisible , mainView . ContentViewState ) ;
41
+ var richTextView = ( MockRichTextView ) mainViewModel . ActiveDocumentView ! ;
42
+ var richTextViewModel = richTextView . ViewModel ;
43
+ var shellService = shellViewModel . ShellService ;
44
+
45
+ Assert . IsFalse ( shellService . ActiveZoomCommands . ZoomInCommand . CanExecute ( null ) ) ;
46
+ richTextViewModel . IsVisible = true ;
47
+ Assert . IsTrue ( shellService . ActiveZoomCommands . ZoomInCommand . CanExecute ( null ) ) ;
48
+ Assert . AreSame ( richTextViewModel , shellService . ActiveEditingCommands ) ;
49
+
50
+ richTextViewModel . Document . Modified = true ;
51
+
52
+ bool showDialogActionShown = false ;
53
+ MockSaveChangesView . ShowDialogAction = v =>
54
+ {
55
+ showDialogActionShown = true ;
56
+ v . ViewModel . NoCommand . Execute ( null ) ;
57
+ } ;
58
+
59
+ mainViewModel . FileService . CloseCommand . Execute ( null ) ;
60
+ Assert . IsTrue ( showDialogActionShown ) ;
61
+ Assert . IsNull ( mainViewModel . ActiveDocumentView ) ;
62
+ Assert . AreEqual ( ContentViewState . StartViewVisible , mainView . ContentViewState ) ;
63
+ }
26
64
}
0 commit comments