コード例 #1
0
        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);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
ファイル: AnkhContextTest.cs プロジェクト: windygu/AnkhSVN
 public override void SetUp()
 {
     base.SetUp();
     TestUtils.ToggleAnkh(false, "7.1");
     this.dteFactory = DteFactory.Create2003();
     this.ExtractWorkingCopy();
 }
コード例 #4
0
ファイル: AnkhContextTest.cs プロジェクト: necora/ank_git
 public override void SetUp()
 {
     base.SetUp();
     TestUtils.ToggleAnkh( false, "7.1" );
     this.dteFactory = DteFactory.Create2003();
     this.ExtractWorkingCopy();
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        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);
        }