private void ProcessAnalyzer(DiagnosticAnalyzer analyzer, SqaleModel root) { foreach(DiagnosticDescriptor diagnostic in analyzer.SupportedDiagnostics) { SqaleDescriptor sqaleDescriptor = new SqaleDescriptor { Remediation = new SqaleRemediation { RuleKey = diagnostic.Id }, SubCharacteristic = "MAINTAINABILITY_COMPLIANCE" }; sqaleDescriptor.Remediation.Properties.AddRange(new[] { new SqaleRemediationProperty { Key = "remediationFunction", Text = "CONSTANT_ISSUE" }, new SqaleRemediationProperty { Key = "offset", Value = this.remediationConstantValue, Text = string.Empty } }); root.Sqale.Add(sqaleDescriptor); } }
public SqaleModel GenerateSqaleData(IEnumerable<DiagnosticAnalyzer> analyzers, string remediationValue) { if (analyzers == null) { throw new ArgumentNullException("analyzers"); } Debug.Assert(remediationValue.EndsWith("min"), "Expecting a remediation value in the form '15min'"); this.remediationConstantValue = remediationValue; SqaleModel root = new SqaleModel(); foreach(DiagnosticAnalyzer analyzer in analyzers) { ProcessAnalyzer(analyzer, root); } return root; }
public void Generate_ValidSqaleFileSpecified_TemplateFileNotCreated() { // Arrange string outputDir = TestUtils.CreateTestDirectory(this.TestContext, ".out"); RemoteRepoBuilder remoteRepoBuilder = new RemoteRepoBuilder(this.TestContext); AnalyzerPluginGenerator apg = CreateTestSubjectWithFakeRemoteRepo(remoteRepoBuilder); CreatePackageInFakeRemoteRepo(remoteRepoBuilder, "dummy.id", "1.1"); // Create a dummy sqale file string dummySqaleFilePath = Path.Combine(outputDir, "inputSqale.xml"); SqaleModel dummySqale = new SqaleModel(); Serializer.SaveModel(dummySqale, dummySqaleFilePath); ProcessedArgs args = CreateArgs("dummy.id", "1.1", "cs", dummySqaleFilePath, false, outputDir); // Act bool result = apg.Generate(args); // Assert Assert.IsTrue(result, "Expecting generation to have succeeded"); AssertSqaleTemplateDoesNotExist(outputDir); }