private void DumpLists(BuildLog actualResult, string itemType, string[] expected) { TestContext.WriteLine(""); TestContext.WriteLine("Dumping <" + itemType + "> list: expected"); foreach (var item in expected) { TestContext.WriteLine("\t{0}", item); } TestContext.WriteLine(""); TestContext.WriteLine(""); TestContext.WriteLine("Dumping <" + itemType + "> list: actual"); foreach (var item in actualResult.GetCapturedItemValues(itemType)) { TestContext.WriteLine("\t{0}", item.Value); } TestContext.WriteLine(""); }
/// <summary> /// Checks whether there is a single "SonarQubeSetting" item with the expected name and setting value /// </summary> private static void AssertExpectedAnalysisSetting(BuildLog actualResult, string settingName, string expectedValue) { /* The equivalent XML would look like this: * <ItemGroup> * <SonarQubeSetting Include="settingName"> * <Value>expectedValue</Value * </SonarQubeSetting> * </ItemGroup> */ var settings = actualResult.GetCapturedItemValues(BuildTaskConstants.SettingItemName); settings.Should().NotBeEmpty(); var matches = settings.Where(v => v.Value.Equals(settingName, System.StringComparison.Ordinal)).ToList(); matches.Should().ContainSingle($"Only one and only expecting one SonarQubeSetting with include value of '{0}' to exist. Count: {matches.Count}", settingName); var item = matches[0]; var value = item.Metadata.SingleOrDefault(v => v.Name.Equals(BuildTaskConstants.SettingValueMetadataName)); value.Should().NotBeNull(); value.Value.Should().Be(expectedValue, "SonarQubeSetting with include value '{0}' does not have the expected value", settingName); }
/// <summary> /// Checks that a SonarQubeSetting does not exist /// </summary> private static void AssertAnalysisSettingDoesNotExist(BuildLog actualResult, string settingName) { var matches = actualResult.GetCapturedItemValues(BuildTaskConstants.SettingItemName); matches.Should().BeEmpty("Not expected SonarQubeSetting with include value of '{0}' to exist. Actual occurrences: {1}", settingName, matches.Count()); }