コード例 #1
0
        public void GenerateAndPersistSarifFile_NoResults_WritesToFile()
        {
            using (ShimsContext.Create())
            {
                Boolean fileWriteInvoked = false;

                System.IO.Fakes.ShimFile.WriteAllTextStringString = (_, __) =>
                {
                    fileWriteInvoked = true;
                };

                ShimResultsFileSarifMapper.GenerateEmbeddedFilesStringGuidBooleanString = (_, __, ___, ____) =>
                {
                    return(new Dictionary <string, FileData>()
                    {
                        { ScreenShotPathValue, new FileData() },
                        { ToolOutputPathValue, new FileData() }
                    });
                };

                ShimResultsFileSarifMapper.TraverseTreeDepthFirstGuid = (_) =>
                {
                    return(new List <Tuple <Rule, Result> >());;
                };

                Microsoft.CodeAnalysis.Sarif.Writers.Fakes.ShimSarifLogger.AllInstances.LogIRuleResult = (_, __, ___) => { };
                ResultsFileSarifMapper.GenerateAndPersistSarifFile(SystemPath, guid, false);
                Assert.IsTrue(fileWriteInvoked);
            }
        }
コード例 #2
0
ファイル: SaveAction.cs プロジェクト: waabid/axe-windows
 /// <summary>
 /// Will generate and save the sarif file at the specifed path from the specified element downwards
 /// </summary>
 /// <param name="path"> The path at which the generated file needs to be persisted </param>
 /// <param name="ecId"> the guid of the root element </param>
 /// <param name="deleteGeneratedResultsFile"> Whether the generated results should be deleted </param>
 /// <param name="otherProperties"></param>
 public static void SaveSarifFile(string path, Guid ecId, Boolean deleteGeneratedResultsFile)
 {
     ResultsFileSarifMapper.GenerateAndPersistSarifFile(path, ecId, deleteGeneratedResultsFile);
 }