public void ProjectFileModelWatcher_Initialize_SubscribesAndCausesCallback() { var editorState = IProjectFileEditorPresenterFactory.Create(); var unconfiguredProject = UnconfiguredProjectFactory.CreateWithUnconfiguredProjectAdvanced(); var watcher = new ProjectFileModelWatcher(editorState, unconfiguredProject); watcher.InitializeModelWatcher(); var unconfiguredProjectAdvanced = Mock.Get(unconfiguredProject).As <UnconfiguredProjectAdvanced>(); unconfiguredProjectAdvanced.Raise(u => u.ChangingProjectFile += null, EventArgs.Empty); Mock.Get(editorState).Verify(e => e.ScheduleProjectFileUpdate(), Times.Once); }
public void ProjectFileModelWatcher_Dispose_Unsubscribes() { var editorState = IProjectFileEditorPresenterFactory.Create(); var unconfiguredProject = UnconfiguredProjectFactory.CreateWithUnconfiguredProjectAdvanced(); var watcher = new ProjectFileModelWatcher(editorState, unconfiguredProject); watcher.InitializeModelWatcher(); var unconfiguredProjectAdvanced = Mock.Get(unconfiguredProject).As <UnconfiguredProjectAdvanced>(); unconfiguredProjectAdvanced.Raise(u => u.ChangingProjectFile += null, EventArgs.Empty); Mock.Get(editorState).Verify(e => e.ScheduleProjectFileUpdate(), Times.Once); watcher.Dispose(); // Still should have only had one call to ScheduleProjectFileUpdate, as the watcher should be unsubscribed unconfiguredProjectAdvanced.Raise(u => u.ChangingProjectFile += null, EventArgs.Empty); Mock.Get(editorState).Verify(e => e.ScheduleProjectFileUpdate(), Times.Once); }