public void DocumentProcessed_NewWorkQueued_RestartsTimer() { // Arrange var processedOpenDocument = TestDocumentSnapshot.Create(OpenedDocument.FilePath); var codeDocument = CreateCodeDocument(SingleDiagnosticCollection); processedOpenDocument.With(codeDocument); var languageServerDocument = Mock.Of <ILanguageServerDocument>(); var languageServer = Mock.Of <ILanguageServer>(server => server.Document == languageServerDocument); using (var publisher = new TestRazorDiagnosticsPublisher(Dispatcher, languageServer, LoggerFactory) { BlockBackgroundWorkCompleting = new ManualResetEventSlim(initialState: true), NotifyBackgroundWorkCompleting = new ManualResetEventSlim(initialState: false), }) { publisher.Initialize(ProjectManager); publisher.DocumentProcessed(processedOpenDocument); Assert.True(publisher.NotifyBackgroundWorkCompleting.Wait(TimeSpan.FromSeconds(2))); publisher.NotifyBackgroundWorkCompleting.Reset(); // Act publisher.DocumentProcessed(processedOpenDocument); publisher.BlockBackgroundWorkCompleting.Set(); // Assert // Verify that background work starts completing "again" Assert.True(publisher.NotifyBackgroundWorkCompleting.Wait(TimeSpan.FromSeconds(2))); } }
public void DocumentProcessed_NewWorkQueued_RestartsTimer() { // Arrange var processedOpenDocument = TestDocumentSnapshot.Create(OpenedDocument.FilePath); var codeDocument = CreateCodeDocument(SingleDiagnosticCollection); processedOpenDocument.With(codeDocument); // ILanguageServerDocument var languageServerDocument = new Mock <ITextDocumentLanguageServer>(MockBehavior.Strict).Object; Mock.Get(languageServerDocument).Setup(d => d.SendNotification(It.IsAny <IRequest>())).Verifiable(); using (var publisher = new TestRazorDiagnosticsPublisher(Dispatcher, languageServerDocument, LoggerFactory) { BlockBackgroundWorkCompleting = new ManualResetEventSlim(initialState: true), NotifyBackgroundWorkCompleting = new ManualResetEventSlim(initialState: false), }) { publisher.Initialize(ProjectManager); publisher.DocumentProcessed(processedOpenDocument); Assert.True(publisher.NotifyBackgroundWorkCompleting.Wait(TimeSpan.FromSeconds(2))); publisher.NotifyBackgroundWorkCompleting.Reset(); // Act publisher.DocumentProcessed(processedOpenDocument); publisher.BlockBackgroundWorkCompleting.Set(); // Assert // Verify that background work starts completing "again" Assert.True(publisher.NotifyBackgroundWorkCompleting.Wait(TimeSpan.FromSeconds(2))); } }