@@ -158,6 +158,44 @@ await RunOnDispatcherThreadAsync(() =>
158
158
Assert . True ( serializationSuccessful ) ;
159
159
}
160
160
161
+ [ Fact ]
162
+ public async Task ProjectManager_Changed_DocumentOpened_InitializedProject_NoFile_Active_Publishes ( )
163
+ {
164
+ // Arrange
165
+ var serializationSuccessful = false ;
166
+ var hostProject = new HostProject ( @"C:\path\to\project.csproj" , @"C:\path\to\obj" , RazorConfiguration . Default , rootNamespace : "TestRootNamespace" ) ;
167
+ var hostDocument = new HostDocument ( @"C:\path\to\file.razor" , "file.razor" ) ;
168
+ _projectSnapshotManager . ProjectAdded ( hostProject ) ;
169
+ _projectSnapshotManager . ProjectWorkspaceStateChanged ( hostProject . Key , ProjectWorkspaceState . Default ) ;
170
+ _projectSnapshotManager . DocumentAdded ( hostProject . Key , hostDocument , new EmptyTextLoader ( hostDocument . FilePath ) ) ;
171
+ var projectSnapshot = _projectSnapshotManager . GetProjects ( ) [ 0 ] ;
172
+ var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin" ;
173
+ _projectConfigurationFilePathStore . Set ( projectSnapshot . Key , expectedConfigurationFilePath ) ;
174
+ var publisher = new TestRazorProjectInfoPublisher (
175
+ _projectConfigurationFilePathStore ,
176
+ onSerializeToFile : ( snapshot , configurationFilePath ) =>
177
+ {
178
+ Assert . Equal ( expectedConfigurationFilePath , configurationFilePath ) ;
179
+ serializationSuccessful = true ;
180
+ } ,
181
+ configurationFileExists : false )
182
+ {
183
+ EnqueueDelay = 10 ,
184
+ _active = true
185
+ } ;
186
+ publisher . Initialize ( _projectSnapshotManager ) ;
187
+
188
+ // Act
189
+ await RunOnDispatcherThreadAsync ( ( ) =>
190
+ {
191
+ _projectSnapshotManager . DocumentOpened ( hostProject . Key , hostDocument . FilePath , SourceText . From ( string . Empty ) ) ;
192
+ } ) ;
193
+
194
+ // Assert
195
+ Assert . Empty ( publisher . DeferredPublishTasks ) ;
196
+ Assert . True ( serializationSuccessful ) ;
197
+ }
198
+
161
199
[ Theory ]
162
200
[ InlineData ( ProjectChangeKind . DocumentAdded ) ]
163
201
[ InlineData ( ProjectChangeKind . DocumentRemoved ) ]
0 commit comments