Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        public async Task Dispose_ValidateSolutionEventsEstablished()
        {
            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);

            await rlm.DisposeAsync();

            Assert.Equal <uint>(0, rlm.SolutionEventsCookie);
        }
Beispiel #4
0
        public async Task Dispose_ValidateRegisterProject()
        {
            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(@"c:\temp\project1.csproj");

            await rlm.RegisterProjectAsync(reloadableProjectMock.Object);

            Assert.Equal <int>(1, rlm.RegisteredProjects.Count);
            Assert.Same(reloadableProjectMock.Object, rlm.RegisteredProjects.First().Key);
            reloadableProjectMock.VerifyAll();
        }