public AssertNumberOfAbortRequests ( int expected ) : void | ||
expected | int | |
리턴 | void |
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 void BindingWorkflow_DownloadQualityProfile_Failure() { // Setup BindingWorkflow testSubject = this.CreateTestSubject(); ConfigurableProgressController controller = new ConfigurableProgressController(); var notifications = new ConfigurableProgressStepExecutionEvents(); var language = Language.CSharp; this.ConfigureProfileExport(null, language); // Act testSubject.DownloadQualityProfile(controller, CancellationToken.None, notifications, new[] { language }); // Verify Assert.IsFalse(testSubject.Rulesets.ContainsKey(Language.VBNET), "Not expecting any rules for this language"); Assert.IsFalse(testSubject.Rulesets.ContainsKey(language), "Not expecting any rules"); controller.AssertNumberOfAbortRequests(1); notifications.AssertProgressMessages(Strings.DownloadingQualityProfileProgressMessage); this.outputWindowPane.AssertOutputStrings(1); var expectedOutput = string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.QualityProfileDownloadFailedMessageFormat, string.Empty, string.Empty, language.Name)); this.outputWindowPane.AssertOutputStrings(expectedOutput); }
public void BindingWorkflow_DiscoverProjects_NoMatchingProjects_AbortsWorkflow() { // Arrange ThreadHelper.SetCurrentThreadAsUIThread(); var controller = new ConfigurableProgressController(); var progressEvents = new ConfigurableProgressStepExecutionEvents(); // Act & Common Assert BindingWorkflow_DiscoverProjects_GenericPart(controller, progressEvents, 0, 0); // Assert controller.AssertNumberOfAbortRequests(1); }
public void BindingWorkflow_DownloadQualityProfile_Success() { // Setup const string QualityProfileName = "SQQualityProfileName"; const string SonarQubeProjectName = "SQProjectName"; var projectInfo = new ProjectInformation { Key = "key", Name = SonarQubeProjectName }; BindingWorkflow testSubject = this.CreateTestSubject(projectInfo); ConfigurableProgressController controller = new ConfigurableProgressController(); var notifications = new ConfigurableProgressStepExecutionEvents(); RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSetWithRuleIds(new[] { "Key1", "Key2" }); var expectedRuleSet = new RuleSet(ruleSet) { NonLocalizedDisplayName = string.Format(Strings.SonarQubeRuleSetNameFormat, SonarQubeProjectName, QualityProfileName), NonLocalizedDescription = "\r\nhttp://connected/profiles/show?key=" }; var nugetPackages = new[] { new PackageName("myPackageId", new SemanticVersion("1.0.0")) }; var additionalFiles = new[] { new AdditionalFile { FileName = "abc.xml", Content = new byte[] { 1, 2, 3 } } }; RoslynExportProfile export = RoslynExportProfileHelper.CreateExport(ruleSet, nugetPackages, additionalFiles); var language = Language.VBNET; QualityProfile profile = this.ConfigureProfileExport(export, language); profile.Name = QualityProfileName; // Act testSubject.DownloadQualityProfile(controller, CancellationToken.None, notifications, new[] { language }); // Verify RuleSetAssert.AreEqual(expectedRuleSet, testSubject.Rulesets[language], "Unexpected rule set"); Assert.AreSame(profile, testSubject.QualityProfiles[language]); VerifyNuGetPackgesDownloaded(nugetPackages, testSubject, language); controller.AssertNumberOfAbortRequests(0); notifications.AssertProgress( 0.0, 1.0); notifications.AssertProgressMessages(Strings.DownloadingQualityProfileProgressMessage, string.Empty); this.outputWindowPane.AssertOutputStrings(1); var expectedOutput = string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.QualityProfileDownloadSuccessfulMessageFormat, QualityProfileName, string.Empty, language.Name)); this.outputWindowPane.AssertOutputStrings(expectedOutput); }
public void BindingWorkflow_DownloadQualityProfile_Success() { // Setup BindingWorkflow testSubject = this.CreateTestSubject(); ConfigurableProgressController controller = new ConfigurableProgressController(); var notifications = new ConfigurableProgressStepExecutionEvents(); RuleSet ruleSet = TestRuleSetHelper.CreateTestRuleSetWithRuleIds(new[] { "Key1", "Key2" }); var nugetPackages = new[] { new PackageName("myPackageId", new SemanticVersion("1.0.0")) }; var additionalFiles = new[] { new AdditionalFile { FileName = "abc.xml", Content = new byte[] { 1, 2, 3 } } }; RoslynExportProfile export = RoslynExportProfileHelper.CreateExport(ruleSet, nugetPackages, additionalFiles); var language = Language.VBNET; QualityProfile profile = this.ConfigureProfileExport(export, language); // Act testSubject.DownloadQualityProfile(controller, CancellationToken.None, notifications, new[] { language }); // Verify RuleSetAssert.AreEqual(ruleSet, testSubject.Rulesets[language], "Unexpected rule set"); Assert.AreSame(profile, testSubject.QualityProfiles[language]); VerifyNuGetPackgesDownloaded(nugetPackages, testSubject); this.outputWindowPane.AssertOutputStrings(0); controller.AssertNumberOfAbortRequests(0); notifications.AssertProgress( 0.0, 1.0, 1.0); notifications.AssertProgressMessages( string.Format(CultureInfo.CurrentCulture, Strings.DownloadingQualityProfileProgressMessage, language.Name), string.Empty, Strings.QualityProfileDownloadedSuccessfulMessage); }
public void BindingWorkflow_DiscoverProjects_NoMatchingProjects_AbortsWorkflow() { // Setup ThreadHelper.SetCurrentThreadAsUIThread(); var controller = new ConfigurableProgressController(); var progressEvents = new ConfigurableProgressStepExecutionEvents(); this.projectSystemHelper.FilteredProjects = null; var testSubject = this.CreateTestSubject(); // Act testSubject.DiscoverProjects(controller, progressEvents); // Verify Assert.AreEqual(0, testSubject.BindingProjects.Count, "Expected no projects selected for binding"); progressEvents.AssertProgressMessages(Strings.DiscoveringSolutionProjectsProgressMessage); this.outputWindowPane.AssertOutputStrings(Strings.NoProjectsApplicableForBinding); controller.AssertNumberOfAbortRequests(1); }
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 void BindingWorkflow_DownloadQualityProfile_Failure() { // Setup BindingWorkflow testSubject = this.CreateTestSubject(); ConfigurableProgressController controller = new ConfigurableProgressController(); var language = Language.CSharp; this.ConfigureProfileExport(null, language); // Act testSubject.DownloadQualityProfile(controller, CancellationToken.None, new ConfigurableProgressStepExecutionEvents(), new[] { language }); // Verify Assert.IsFalse(testSubject.Rulesets.ContainsKey(Language.VBNET), "Not expecting any rules for this language"); Assert.IsFalse(testSubject.Rulesets.ContainsKey(language), "Not expecting any rules"); this.outputWindowPane.AssertOutputStrings(1); controller.AssertNumberOfAbortRequests(1); }