public void SonarQubeServiceWrapper_TryGetQualityProfile_FullFunctionality() { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider)) { // Setup Language language = Language.CSharp; QualityProfile profile = CreateRandomQualityProfile(language); var project = new ProjectInformation { Key = "awesome1", Name = "My Awesome Project" }; var changeLog = new QualityProfileChangeLog { Page = 1, PageSize = 1, Total = 1, Events = new QualityProfileChangeLogEvent[] { new QualityProfileChangeLogEvent { Date = DateTime.Now } } }; ConnectionInformation conn = ConfigureValidConnection(testSubject, new[] { project }); // Setup test server RegisterQualityProfileChangeLogValidator(testSubject); RequestHandler getProfileHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileUrl(language, project), ctx => ServiceQualityProfiles(ctx, new[] { profile }) ); RequestHandler changeLogHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileChangeLogUrl(profile), ctx => ServiceChangeLog(ctx, changeLog) ); // Act QualityProfile actualProfile; Assert.IsTrue(testSubject.TryGetQualityProfile(conn, project, language, CancellationToken.None, out actualProfile), "TryGetExportProfile failed unexpectedly"); // Verify Assert.IsNotNull(actualProfile, "Expected a profile to be returned"); Assert.AreEqual(profile.Key, actualProfile.Key); Assert.AreEqual(profile.Name, actualProfile.Name); Assert.AreEqual(changeLog.Events[0].Date, actualProfile.QualityProfileTimestamp); getProfileHandler.AssertHandlerCalled(1); changeLogHandler.AssertHandlerCalled(1); this.outputWindowPane.AssertOutputStrings(0); } }
private void SonarQubeServiceWrapper_TryGetQualityProfile_ReducedFunctionality(Language language) { using (var testSubject = new TestableSonarQubeServiceWrapper(this.serviceProvider)) { // Setup QualityProfile profile = CreateRandomQualityProfile(language); var project = new ProjectInformation { Key = "awesome1", Name = "My Awesome Project" }; ConnectionInformation conn = ConfigureValidConnection(testSubject, new[] { project }); // Setup test server RegisterQualityProfileChangeLogValidator(testSubject); RequestHandler getProfileHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileUrl(language, project), ctx => ServiceQualityProfiles(ctx, new[] { profile }) ); RequestHandler changeLogHandler = testSubject.RegisterRequestHandler( SonarQubeServiceWrapper.CreateQualityProfileChangeLogUrl(profile), ctx => ServiceChangeLog(ctx, null, simulateFault: true) ); // Act QualityProfile actualProfile; Assert.IsTrue(testSubject.TryGetQualityProfile(conn, project, language, CancellationToken.None, out actualProfile), "TryGetExportProfile failed unexpectedly"); // Verify Assert.IsNotNull(actualProfile, "Expected a profile to be returned"); Assert.AreEqual(profile.Key, actualProfile.Key); Assert.AreEqual(profile.Name, actualProfile.Name); Assert.IsNull(actualProfile.QualityProfileTimestamp); getProfileHandler.AssertHandlerCalled(1); changeLogHandler.AssertHandlerCalled(1); this.outputWindowPane.AssertOutputStrings(1); } }