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_DownloadQualityProfile_WhenQualityProfileIsNotAvailable_Fails() { // Arrange BindingWorkflow testSubject = this.CreateTestSubject(); ConfigurableProgressController controller = new ConfigurableProgressController(); var notifications = new ConfigurableProgressStepExecutionEvents(); var language = Language.CSharp; this.ConfigureProfileExport(null, Language.VBNET); // Act testSubject.DownloadQualityProfile(controller, CancellationToken.None, notifications, new[] { language }); // Assert testSubject.Rulesets.Should().NotContainKey(Language.VBNET, "Not expecting any rules for this language"); testSubject.Rulesets.Should().NotContainKey(language, "Not expecting any rules"); controller.NumberOfAbortRequests.Should().Be(1); notifications.AssertProgressMessages(Strings.DownloadingQualityProfileProgressMessage); this.outputWindowPane.AssertOutputStrings(1); var expectedOutput = string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.CannotDownloadQualityProfileForLanguage, language.Name)); this.outputWindowPane.AssertOutputStrings(expectedOutput); }
public void BindingWorkflow_DownloadQualityProfile_WithNoActiveRules_Fails() { // Arrange 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" }); foreach (var rule in ruleSet.Rules) { rule.Action = RuleAction.None; } 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 }); // Assert testSubject.Rulesets.Should().NotContainKey(Language.VBNET, "Not expecting any rules for this language"); testSubject.Rulesets.Should().NotContainKey(language, "Not expecting any rules"); controller.NumberOfAbortRequests.Should().Be(1); notifications.AssertProgressMessages(Strings.DownloadingQualityProfileProgressMessage); this.outputWindowPane.AssertOutputStrings(1); var expectedOutput = string.Format(Strings.SubTextPaddingFormat, string.Format(Strings.NoSonarAnalyzerActiveRulesForQualityProfile, QualityProfileName, language.Name)); this.outputWindowPane.AssertOutputStrings(expectedOutput); }
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); }