public void AndroidStudioConverter_ConvertToSarifIssue_HasNoPropertiesIfAttributeKeyAndSeverity()
        {
            var    uut    = AndroidStudioProblemTests.GetDefaultProblem();
            Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut);

            Assert.IsNull(result.Properties);
        }
        public void AndroidStudioConverter_ConvertToSarifIssue_UsesProblemClassForRuleId()
        {
            var    uut    = AndroidStudioProblemTests.GetDefaultProblem();
            Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut);

            Assert.AreEqual("A Problematic Problem", result.RuleId);
        }
        public void AndroidStudioConverter_ConvertToSarifIssue_EmptyHintsDoNotAffectDescription()
        {
            var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder();

            builder.Description = "hungry EVIL zombies";
            var    uut    = new AndroidStudioProblem(builder);
            Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut);

            Assert.IsNull(result.ShortMessage);
            Assert.AreEqual("hungry EVIL zombies", result.FullMessage);
        }
        public void AndroidStudioConverter_ConvertToSarifIssue_SeverityIsPersistedInProperties()
        {
            var builder = AndroidStudioProblemTests.GetDefaultProblemBuilder();

            builder.Severity = "warning";
            var    uut    = new AndroidStudioProblem(builder);
            Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut);

            result.Properties.Should().Equal(new Dictionary <string, string> {
                { "severity", "warning" }
            });
        }
        /// <summary>Processes an Android Studio log and writes issues therein to an instance of
        /// <see cref="IResultLogWriter"/>.</summary>
        /// <param name="xmlReader">The XML reader from which AndroidStudio format shall be read.</param>
        /// <param name="output">The <see cref="IResultLogWriter"/> to write the output to.</param>
        private void ProcessAndroidStudioLog(XmlReader xmlReader, IResultLogWriter output)
        {
            int problemsDepth = xmlReader.Depth;

            xmlReader.ReadStartElement(_strings.Problems);

            while (xmlReader.Depth > problemsDepth)
            {
                var problem = AndroidStudioProblem.Parse(xmlReader, _strings);
                if (problem != null)
                {
                    output.WriteResult(AndroidStudioConverter.ConvertProblemToSarifIssue(problem));
                }
            }

            xmlReader.ReadEndElement(); // </problems>
        }
        public void AndroidStudioConverter_ConvertToSarifIssue_HintsAreStapledToDescription()
        {
            var builder = new AndroidStudioProblem.Builder
            {
                ProblemClass = "Unused",
                File         = "Unused",
                Description  = "hungry EVIL zombies",
                Hints        = ImmutableArray.Create("comment", "delete")
            };

            var    uut    = new AndroidStudioProblem(builder);
            Result result = AndroidStudioConverter.ConvertProblemToSarifIssue(uut);

            Assert.AreEqual("hungry EVIL zombies", result.ShortMessage);
            Assert.AreEqual(@"hungry EVIL zombies
Possible resolution: comment
Possible resolution: delete", result.FullMessage);
        }
 private static Location GetLocationForBuilder(AndroidStudioProblem.Builder builder)
 {
     return(AndroidStudioConverter.ConvertProblemToSarifIssue(new AndroidStudioProblem(builder)).Locations[0]);
 }