public async Task FilesChanged_CallsProjectToReload(_VSFILECHANGEFLAGS flags) { string projectFile = @"c:\temp\project1.csproj"; var spMock = new IServiceProviderMoq(); spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100)); spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150)); var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object); var reloadableProjectMock = new Mock <IReloadableProject>(MockBehavior.Strict); reloadableProjectMock.Setup(x => x.ProjectFile).Returns(projectFile); reloadableProjectMock.Setup(x => x.ReloadProjectAsync()).Returns(Task.FromResult(ProjectReloadResult.ReloadCompleted)); await rlm.RegisterProjectAsync(reloadableProjectMock.Object); Assert.Equal <int>(1, rlm.RegisteredProjects.Count); // Shorten the normal delay so unit tests run faster ((TaskDelayScheduler)rlm.ReloadDelayScheduler).TaskDelayTime = TimeSpan.FromMilliseconds(20); rlm.FilesChanged(1, new string[1] { projectFile }, new uint[1] { (uint)flags }); await rlm.ReloadDelayScheduler.LatestScheduledTask; reloadableProjectMock.VerifyAll(); }
public async Task FilesChanged_SkipsNonRegisteredProjects() { string projectFile = @"c:\temp\project1.csproj"; var spMock = new IServiceProviderMoq(); spMock.AddService(typeof(IVsFileChangeEx), typeof(SVsFileChangeEx), IVsFileChangeExFactory.CreateWithAdviseUnadviseFileChange(100)); spMock.AddService(typeof(IVsSolution), typeof(SVsSolution), IVsSolutionFactory.CreateWithAdviseUnadviseSolutionEvents(150)); var rlm = new ProjectReloadManager(IProjectThreadingServiceFactory.Create(), spMock, IUserNotificationServicesFactory.ImplementReportErrorInfo(), new Mock <IDialogServices>().Object); var reloadableProjectMock = new Mock <IReloadableProject>(MockBehavior.Strict); reloadableProjectMock.Setup(x => x.ProjectFile).Returns(projectFile); await rlm.RegisterProjectAsync(reloadableProjectMock.Object); Assert.Equal <int>(1, rlm.RegisteredProjects.Count); rlm.FilesChanged(1, new string[1] { projectFile + ".csproj" }, new uint[1] { (uint)_VSFILECHANGEFLAGS.VSFILECHG_Size }); Assert.True(rlm.ReloadDelayScheduler.LatestScheduledTask == null); reloadableProjectMock.VerifyAll(); }