public void PromptSaveSolutionIfDirty() { // Arrange var testSubject = this.CreateTestSubject(); var solution = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solution); // Case 1: Users saves the changes solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_OK; // Act var result = testSubject.PromptSaveSolutionIfDirty(); // Assert result.Should().BeTrue(); this.outputWindowPane.AssertOutputStrings(0); // Case 2: Users cancels the save solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_FALSE; // Act result = testSubject.PromptSaveSolutionIfDirty(); // Assert result.Should().BeFalse(); this.outputWindowPane.AssertOutputStrings(Strings.SolutionSaveCancelledBindAborted); }
public EnumHierarchies(SolutionMock mock) { foreach (var project in mock.Projects) { this.Items.Add(project); } }
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 BindingWorkflow_PromptSaveSolutionIfDirty() { // Arrange var testSubject = this.CreateTestSubject(); var solution = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solution); var controller = new ConfigurableProgressController(); // Case 1: Users saves the changes solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_OK; // Act testSubject.PromptSaveSolutionIfDirty(controller, CancellationToken.None); // Assert this.outputWindowPane.AssertOutputStrings(0); controller.NumberOfAbortRequests.Should().Be(0); // Case 2: Users cancels the save solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_FALSE; // Act testSubject.PromptSaveSolutionIfDirty(controller, CancellationToken.None); // Assert this.outputWindowPane.AssertOutputStrings(Strings.SolutionSaveCancelledBindAborted); controller.NumberOfAbortRequests.Should().Be(1); }
public void TestInitialize() { serviceProvider = new ConfigurableServiceProvider(false); host = new ConfigurableHost(serviceProvider, Dispatcher.CurrentDispatcher); var mefExport1 = MefTestHelpers.CreateExport <IHost>(host); activeSolutionTracker = new ConfigurableActiveSolutionTracker(); var mefExport2 = MefTestHelpers.CreateExport <IActiveSolutionTracker>(activeSolutionTracker); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); solutionMock = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solutionMock); errorListController = new ConfigurableErrorListInfoBarController(); serviceProvider.RegisterService(typeof(IErrorListInfoBarController), errorListController); configProvider = new ConfigurableConfigurationProvider(); serviceProvider.RegisterService(typeof(IConfigurationProviderService), configProvider); loggerMock = new Mock <ILogger>(); vsMonitorMock = new Mock <IVsMonitorSelection>(); vsMonitorMock .Setup(x => x.GetCmdUIContextCookie(ref BoundSolutionUIContext.Guid, out boundSolutionUIContextCookie)) .Returns(VSConstants.S_OK); serviceProvider.RegisterService(typeof(SVsShellMonitorSelection), vsMonitorMock.Object, replaceExisting: true); }
public void TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(false); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); var mefExport1 = MefTestHelpers.CreateExport <IHost>(this.host); this.activeSolutionTracker = new ConfigurableActiveSolutionTracker(); var mefExport2 = MefTestHelpers.CreateExport <IActiveSolutionTracker>(this.activeSolutionTracker); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); this.solutionMock = new SolutionMock(); this.serviceProvider.RegisterService(typeof(SVsSolution), this.solutionMock); this.errorListController = new ConfigurableErrorListInfoBarController(); this.serviceProvider.RegisterService(typeof(IErrorListInfoBarController), this.errorListController); this.solutionBindingInformationProvider = new ConfigurableSolutionBindingInformationProvider(); this.serviceProvider.RegisterService(typeof(ISolutionBindingInformationProvider), this.solutionBindingInformationProvider); this.solutionBindingSerializer = new ConfigurableSolutionBindingSerializer(); this.serviceProvider.RegisterService(typeof(ISolutionBindingSerializer), solutionBindingSerializer); this.sonarLintOutputMock = new Mock <ISonarLintOutput>(); }
public void TestInitialize() { this.solutionMock = new SolutionMock(); this.serviceProvider = new ConfigurableServiceProvider(); this.serviceProvider.RegisterService(typeof(SVsSolution), this.solutionMock); this.testSubject = new ProjectSystemHelper(this.serviceProvider); this.projectFilter = new ConfigurableProjectSystemFilter(); this.serviceProvider.RegisterService(typeof(IProjectSystemFilter), this.projectFilter); }
public void TestInitialize() { this.dte = new DTEMock(); this.serviceProvider = new ConfigurableServiceProvider(); this.solutionMock = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln")); this.projectMock = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj")); var outputWindow = new ConfigurableVsOutputWindow(); this.outputPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); }
public void BindingWorkflow_SilentSaveSolutionIfDirty() { // Arrange var testSubject = this.CreateTestSubject(); var solution = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solution); solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_OK; // Act testSubject.SilentSaveSolutionIfDirty(); // Assert this.outputWindowPane.AssertOutputStrings(0); }
public void TestInitialize() { this.dte = new DTEMock(); this.serviceProvider = new ConfigurableServiceProvider(); this.solutionMock = new SolutionMock(dte, Path.Combine(SolutionRoot, "xxx.sln")); this.projectMock = this.solutionMock.AddOrGetProject(Path.Combine(SolutionRoot, @"Project\project.proj")); this.projectSystemHelper = new ConfigurableVsProjectSystemHelper(this.serviceProvider); var outputWindow = new ConfigurableVsOutputWindow(); this.outputPane = outputWindow.GetOrCreateSonarLintPane(); this.serviceProvider.RegisterService(typeof(SVsOutputWindow), outputWindow); this.serviceProvider.RegisterService(typeof(IProjectSystemHelper), projectSystemHelper); this.testSubject = new SolutionRuleSetsInformationProvider(this.serviceProvider, new SonarLintOutputLogger(serviceProvider)); }
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(); }
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 TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(false); this.host = new ConfigurableHost(this.serviceProvider, Dispatcher.CurrentDispatcher); var mefExport1 = MefTestHelpers.CreateExport<IHost>(this.host); this.activeSolutionTracker = new ConfigurableActiveSolutionTracker(); var mefExport2 = MefTestHelpers.CreateExport<IActiveSolutionTracker>(this.activeSolutionTracker); var mefModel = ConfigurableComponentModel.CreateWithExports(mefExport1, mefExport2); this.serviceProvider.RegisterService(typeof(SComponentModel), mefModel, replaceExisting: true); this.solutionMock = new SolutionMock(); this.serviceProvider.RegisterService(typeof(SVsSolution), this.solutionMock); this.errorListController = new ConfigurableErrorListInfoBarController(); this.serviceProvider.RegisterService(typeof(IErrorListInfoBarController), this.errorListController); this.solutionBindingInformationProvider = new ConfigurableSolutionBindingInformationProvider(); this.serviceProvider.RegisterService(typeof(ISolutionBindingInformationProvider), this.solutionBindingInformationProvider); }
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(); }
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 TestInitialize() { this.serviceProvider = new ConfigurableServiceProvider(); this.solutionMock = new SolutionMock(); this.serviceProvider.RegisterService(typeof(SVsSolution), this.solutionMock); }
public void BindingWorkflow_PromptSaveSolutionIfDirty() { // Setup var testSubject = this.CreateTestSubject(); var solution = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solution); var controller = new ConfigurableProgressController(); // Case 1: Users saves the changes solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_OK; // Act testSubject.PromptSaveSolutionIfDirty(controller, CancellationToken.None); // Verify this.outputWindowPane.AssertOutputStrings(0); controller.AssertNumberOfAbortRequests(0); // Case 2: Users cancels the save solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_FALSE; // Act testSubject.PromptSaveSolutionIfDirty(controller, CancellationToken.None); // Verify this.outputWindowPane.AssertOutputStrings(Strings.SolutionSaveCancelledBindAborted); controller.AssertNumberOfAbortRequests(1); }
public _ProjectsMock(SolutionMock parent) { this.parent = parent; }
public void BindingWorkflow_SilentSaveSolutionIfDirty() { // Setup var testSubject = this.CreateTestSubject(); var solution = new SolutionMock(); serviceProvider.RegisterService(typeof(SVsSolution), solution); solution.SaveSolutionElementAction = (options, hierarchy, docCookie) => VSConstants.S_OK; // Act testSubject.SilentSaveSolutionIfDirty(); // Verify this.outputWindowPane.AssertOutputStrings(0); }