public void GlobalJsonRemover_RemovesJson_WhenExists() { UnitTestHelper.IsRunningUnitTests = true; var solution = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback); var projectItem = ProjectItemFactory.Create(); var dteSolution = SolutionFactory.ImplementFindProjectItem(path => { Assert.Equal(Path.Combine(Directory, "global.json"), path); return(projectItem); }); var dte = DteFactory.ImplementSolution(() => dteSolution); var serviceProvider = IServiceProviderFactory.ImplementGetService(t => { if (typeof(SVsSolution) == t) { return(solution); } if (typeof(DTE) == t) { return(dte); } Assert.False(true); throw new InvalidOperationException(); }); var remover = new GlobalJsonRemover(serviceProvider); Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0)); Mock.Get(projectItem).Verify(p => p.Remove(), Times.Once); }
public void GlobalJsonRemover_NoJson_DoesntCrash() { UnitTestHelper.IsRunningUnitTests = true; var solution = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback); var dteSolution = SolutionFactory.ImplementFindProjectItem(path => { Assert.Equal(Path.Combine(Directory, "global.json"), path); return(null); }); var dte = DteFactory.ImplementSolution(() => dteSolution); var serviceProvider = IServiceProviderFactory.ImplementGetService(t => { if (typeof(SVsSolution) == t) { return(solution); } if (typeof(DTE) == t) { return(dte); } Assert.False(true); throw new InvalidOperationException(); }); var remover = new GlobalJsonRemover(serviceProvider, IFileSystemFactory.Create()); GlobalJsonRemover.Remover = remover; Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0)); }
public override void SetUp() { base.SetUp(); TestUtils.ToggleAnkh(false, "7.1"); this.dteFactory = DteFactory.Create2003(); this.ExtractWorkingCopy(); }
public override void SetUp() { base.SetUp(); TestUtils.ToggleAnkh( false, "7.1" ); this.dteFactory = DteFactory.Create2003(); this.ExtractWorkingCopy(); }
public void DTE_ReturnsServiceProviderGetService() { var dte = DteFactory.Create(); var serviceProvider = IServiceProviderFactory.Create(typeof(SDTE), dte); var dteServices = CreateInstance(serviceProvider); var result = dteServices.Dte; Assert.Same(dte, result); }
public void Solution_ReturnsServiceProviderGetService() { var solution = SolutionFactory.Create(); var dte = DteFactory.ImplementSolution(() => solution); var serviceProvider = IServiceProviderFactory.Create(typeof(SDTE), dte); var dteServices = CreateInstance(serviceProvider); var result = dteServices.Solution; Assert.Same(solution, result); }
public void GlobalJsonRemover_AfterRemoval_UnadvisesEvents() { UnitTestHelper.IsRunningUnitTests = true; var globalJsonPath = Path.Combine(Directory, "global.json"); var solution = IVsSolutionFactory.CreateWithSolutionDirectory(DirectoryInfoCallback); var projectItem = ProjectItemFactory.Create(); var dteSolution = SolutionFactory.ImplementFindProjectItem(path => { Assert.Equal(globalJsonPath, path); return(projectItem); }); var dte = DteFactory.ImplementSolution(() => dteSolution); var serviceProvider = IServiceProviderFactory.ImplementGetService(t => { if (typeof(SVsSolution) == t) { return(solution); } if (typeof(DTE) == t) { return(dte); } Assert.False(true); throw new InvalidOperationException(); }); var fileSystem = IFileSystemFactory.Create(); fileSystem.Create(globalJsonPath); var remover = new GlobalJsonRemover(serviceProvider, fileSystem) { SolutionCookie = 1234 }; GlobalJsonRemover.Remover = remover; Assert.Equal(VSConstants.S_OK, remover.OnAfterOpenSolution(null, 0)); Mock.Get(solution).Verify(s => s.UnadviseSolutionEvents(1234), Times.Once); }