internal /*for testing purposes*/ void PromptSaveSolutionIfDirty(IProgressController controller, CancellationToken token)
        {
            if (!VsShellUtils.SaveSolution(this.host, silent: false))
            {
                VsShellUtils.WriteToSonarLintOutputPane(this.host, Strings.SolutionSaveCancelledBindAborted);

                this.AbortWorkflow(controller, token);
            }
        }
        public bool PromptSaveSolutionIfDirty()
        {
            var result = VsShellUtils.SaveSolution(this.host, silent: false);

            if (!result)
            {
                this.host.Logger.WriteLine(Strings.SolutionSaveCancelledBindAborted);
            }
            return(result);
        }
Example #3
0
        public void VsShellUtils_SaveSolution_Silent()
        {
            // Setup
            var serviceProvider = new ConfigurableServiceProvider();
            var solution        = new SolutionMock();

            serviceProvider.RegisterService(typeof(SVsSolution), solution);
            solution.SaveSolutionElementAction = (options, hierarchy, docCookie) =>
            {
                Assert.AreEqual(__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, (__VSSLNSAVEOPTIONS)options, "Unexpected save options");
                Assert.IsNull(hierarchy, "Expecting the scope to be the whole solution");
                Assert.AreEqual(0U, docCookie, "Expecting the scope to be the whole solution");

                return(VSConstants.S_OK);
            };

            // Act + Verify
            Assert.IsTrue(VsShellUtils.SaveSolution(serviceProvider, silent: true));
        }
        public void VsShellUtils_SaveSolution_Silent()
        {
            // Arrange
            var serviceProvider = new ConfigurableServiceProvider();
            var solution        = new SolutionMock();

            serviceProvider.RegisterService(typeof(SVsSolution), solution);
            solution.SaveSolutionElementAction = (options, hierarchy, docCookie) =>
            {
                ((__VSSLNSAVEOPTIONS)options).Should().Be(__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, "Unexpected save options");
                hierarchy.Should().BeNull("Expecting the scope to be the whole solution");
                docCookie.Should().Be(0U, "Expecting the scope to be the whole solution");

                return(VSConstants.S_OK);
            };

            // Act + Assert
            VsShellUtils.SaveSolution(serviceProvider, silent: true).Should().BeTrue();
        }
Example #5
0
        public void VsShellUtils_SaveSolution_Prompt()
        {
            // Setup
            var serviceProvider = new ConfigurableServiceProvider();
            var solution        = new SolutionMock();

            serviceProvider.RegisterService(typeof(SVsSolution), solution);
            int hrResult = 0;

            solution.SaveSolutionElementAction = (options, hierarchy, docCookie) =>
            {
                Assert.AreEqual(__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty | __VSSLNSAVEOPTIONS.SLNSAVEOPT_PromptSave, (__VSSLNSAVEOPTIONS)options, "Unexpected save options");
                Assert.IsNull(hierarchy, "Expecting the scope to be the whole solution");
                Assert.AreEqual(0U, docCookie, "Expecting the scope to be the whole solution");

                return(hrResult);
            };

            // Case 1: user selected 'Yes'
            hrResult = VSConstants.S_OK; //0

            // Act + Verify
            Assert.IsTrue(VsShellUtils.SaveSolution(serviceProvider, silent: false));

            // Case 2: user selected 'No'
            hrResult = VSConstants.S_FALSE; //1

            // Act + Verify
            Assert.IsFalse(VsShellUtils.SaveSolution(serviceProvider, silent: false));

            // Case 3: user selected 'Cancel'
            hrResult = VSConstants.E_ABORT;

            // Act + Verify
            Assert.IsFalse(VsShellUtils.SaveSolution(serviceProvider, silent: false));
        }
        public void VsShellUtils_SaveSolution_Prompt()
        {
            // Arrange
            var serviceProvider = new ConfigurableServiceProvider();
            var solution        = new SolutionMock();

            serviceProvider.RegisterService(typeof(SVsSolution), solution);
            int hrResult = 0;

            solution.SaveSolutionElementAction = (options, hierarchy, docCookie) =>
            {
                ((__VSSLNSAVEOPTIONS)options).Should().Be(__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty | __VSSLNSAVEOPTIONS.SLNSAVEOPT_PromptSave, "Unexpected save options");
                hierarchy.Should().BeNull("Expecting the scope to be the whole solution");
                docCookie.Should().Be(0U, "Expecting the scope to be the whole solution");

                return(hrResult);
            };

            // Case 1: user selected 'Yes'
            hrResult = VSConstants.S_OK; //0

            // Act + Assert
            VsShellUtils.SaveSolution(serviceProvider, silent: false).Should().BeTrue();

            // Case 2: user selected 'No'
            hrResult = VSConstants.S_FALSE; //1

            // Act + Assert
            VsShellUtils.SaveSolution(serviceProvider, silent: false).Should().BeFalse();

            // Case 3: user selected 'Cancel'
            hrResult = VSConstants.E_ABORT;

            // Act + Assert
            VsShellUtils.SaveSolution(serviceProvider, silent: false).Should().BeFalse();
        }
        internal /*for testing purposes*/ void SilentSaveSolutionIfDirty()
        {
            bool saved = VsShellUtils.SaveSolution(this.host, silent: true);

            Debug.Assert(saved, "Should not be cancellable");
        }
        public void SilentSaveSolutionIfDirty()
        {
            bool saved = VsShellUtils.SaveSolution(this.host, silent: true);

            Debug.Assert(saved, "Should not be cancellable");
        }