private void SonarQubeServiceWrapper_TryGetExportProfile(Language language) { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider)) { // Setup QualityProfile profile = CreateRandomQualityProfile(language); var project = new ProjectInformation { Key = "awesome1", Name = "My Awesome Project" }; var expectedExport = RoslynExportProfileHelper.CreateExport(ruleSet: TestRuleSetHelper.CreateTestRuleSet(3)); var roslynExporter = SonarQubeServiceWrapper.CreateRoslynExporterName(language); ConnectionInformation conn = ConfigureValidConnection(testSubject, new[] { project }); // Setup test server RegisterProfileExportQueryValidator(testSubject); RequestHandler getExportHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileExportUrl(profile, language, roslynExporter), ctx => ServiceProfileExport(ctx, expectedExport) ); // Act RoslynExportProfile actualExport; Assert.IsTrue(testSubject.TryGetExportProfile(conn, profile, language, CancellationToken.None, out actualExport), "TryGetExportProfile failed unexpectedly"); // Verify Assert.IsNotNull(actualExport, "Expected a profile export to be returned"); RoslynExportProfileHelper.AssertAreEqual(expectedExport, actualExport); getExportHandler.AssertHandlerCalled(1); } }
public void SonarQubeServiceWrapper_TryGetExportProfile_ArgChecks() { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider, timeoutInMilliseconds: 1)) { RoslynExportProfile actualExport; ConnectionInformation connection = new ConnectionInformation(new Uri("http://valid")); QualityProfile profile = new QualityProfile(); // No connection information Exceptions.Expect <ArgumentNullException>(() => testSubject.TryGetExportProfile(null, profile, Language.CSharp, CancellationToken.None, out actualExport)); // No project information Exceptions.Expect <ArgumentNullException>(() => testSubject.TryGetExportProfile(connection, null, Language.CSharp, CancellationToken.None, out actualExport)); // Invalid language var pascalLanguage = new Language("Pascal", "Pascal", Guid.Empty); Exceptions.Expect <ArgumentOutOfRangeException>(() => testSubject.TryGetExportProfile(connection, profile, pascalLanguage, CancellationToken.None, out actualExport)); // Those are API usage issue which we don't report to the output pane this.outputWindowPane.AssertOutputStrings(0); } }