@@ -18,7 +18,11 @@ public void DocumentsReturnsOpenWorkspaceDocuments()
1818 {
1919 TestEditorOperations editorOperations = new ( )
2020 {
21- OpenDocumentPaths = new [ ] { @"C:\test\one.ps1" , @"C:\test\two.ps1" }
21+ OpenDocuments = new [ ]
22+ {
23+ new WorkspaceOpenDocument ( @"C:\test\one.ps1" , saved : true ) ,
24+ new WorkspaceOpenDocument ( @"C:\test\two.ps1" , saved : true )
25+ }
2226 } ;
2327
2428 EditorWorkspace workspace = new ( editorOperations ) ;
@@ -27,8 +31,16 @@ public void DocumentsReturnsOpenWorkspaceDocuments()
2731
2832 Assert . Collection (
2933 documents ,
30- document => Assert . Equal ( @"C:\test\one.ps1" , document . Path ) ,
31- document => Assert . Equal ( @"C:\test\two.ps1" , document . Path ) ) ;
34+ document =>
35+ {
36+ Assert . Equal ( @"C:\test\one.ps1" , document . Path ) ;
37+ Assert . True ( document . Saved ) ;
38+ } ,
39+ document =>
40+ {
41+ Assert . Equal ( @"C:\test\two.ps1" , document . Path ) ;
42+ Assert . True ( document . Saved ) ;
43+ } ) ;
3244 }
3345
3446 [ Fact ]
@@ -37,7 +49,7 @@ public void DocumentOpenSaveAndCloseUseWorkspaceOperations()
3749 const string filePath = @"C:\test\file.ps1" ;
3850 TestEditorOperations editorOperations = new ( )
3951 {
40- OpenDocumentPaths = new [ ] { filePath }
52+ OpenDocuments = new [ ] { new WorkspaceOpenDocument ( filePath , saved : true ) }
4153 } ;
4254
4355 EditorWorkspace workspace = new ( editorOperations ) ;
@@ -55,23 +67,52 @@ public void DocumentOpenSaveAndCloseUseWorkspaceOperations()
5567 }
5668
5769 [ Fact ]
58- public void DocumentToStringReturnsDocumentPath ( )
70+ public void DocumentToStringReturnsFileNameAndSavedStatus ( )
5971 {
60- const string filePath = @"C:\test\file.ps1" ;
72+ const string savedFilePath = @"C:\test\file.ps1" ;
73+ const string unsavedFilePath = @"C:\test\other.ps1" ;
6174 TestEditorOperations editorOperations = new ( )
6275 {
63- OpenDocumentPaths = new [ ] { filePath }
76+ OpenDocuments = new [ ]
77+ {
78+ new WorkspaceOpenDocument ( savedFilePath , saved : true ) ,
79+ new WorkspaceOpenDocument ( unsavedFilePath , saved : false )
80+ }
6481 } ;
6582
6683 EditorWorkspace workspace = new ( editorOperations ) ;
67- EditorWorkspaceDocument document = Assert . Single ( workspace . Documents ) ;
84+ EditorWorkspaceDocument [ ] documents = workspace . Documents ;
85+
86+ Assert . Collection (
87+ documents ,
88+ document => Assert . Equal ( "file.ps1" , document . ToString ( ) ) ,
89+ document => Assert . Equal ( "other.ps1 [Unsaved]" , document . ToString ( ) ) ) ;
90+ }
91+
92+ [ Fact ]
93+ public void DocumentSavedReturnsWorkspaceSavedState ( )
94+ {
95+ TestEditorOperations editorOperations = new ( )
96+ {
97+ OpenDocuments = new [ ]
98+ {
99+ new WorkspaceOpenDocument ( @"C:\test\saved.ps1" , saved : true ) ,
100+ new WorkspaceOpenDocument ( @"C:\test\unsaved.ps1" , saved : false )
101+ }
102+ } ;
68103
69- Assert . Equal ( filePath , document . ToString ( ) ) ;
104+ EditorWorkspace workspace = new ( editorOperations ) ;
105+ EditorWorkspaceDocument [ ] documents = workspace . Documents ;
106+
107+ Assert . Collection (
108+ documents ,
109+ document => Assert . True ( document . Saved ) ,
110+ document => Assert . False ( document . Saved ) ) ;
70111 }
71112
72113 private sealed class TestEditorOperations : IEditorOperations
73114 {
74- public string [ ] OpenDocumentPaths { get ; set ; } = Array . Empty < string > ( ) ;
115+ public WorkspaceOpenDocument [ ] OpenDocuments { get ; set ; } = Array . Empty < WorkspaceOpenDocument > ( ) ;
75116
76117 public List < string > Calls { get ; } = new ( ) ;
77118
@@ -81,7 +122,7 @@ private sealed class TestEditorOperations : IEditorOperations
81122
82123 public string [ ] GetWorkspacePaths ( ) => new [ ] { @"C:\test" } ;
83124
84- public string [ ] GetWorkspaceOpenDocumentPaths ( ) => OpenDocumentPaths ;
125+ public WorkspaceOpenDocument [ ] GetWorkspaceOpenDocuments ( ) => OpenDocuments ;
85126
86127 public string GetWorkspaceRelativePath ( ScriptFile scriptFile ) => scriptFile . FilePath ;
87128
0 commit comments