コード例 #1
0
        /// <summary>
        /// Write the test framework API frequencies in a JSON file.
        /// </summary>
        private static IDictionary <int, HashSet <string> > ReportTestFrameworkAPIFrequencies(string path, Dictionary <string, int> testFrameworkAPIs)
        {
            var testFrameworkAPIFrequencies = new SortedDictionary <int, HashSet <string> >();

            foreach (var kvp in testFrameworkAPIs)
            {
                if (!testFrameworkAPIFrequencies.ContainsKey(kvp.Value))
                {
                    testFrameworkAPIFrequencies.Add(kvp.Value, new HashSet <string>());
                }

                testFrameworkAPIFrequencies[kvp.Value].Add(kvp.Key);
            }

            string reportFile = $"{Path.Combine(path, TestProjectInfo.TestFrameworkAPIInsightsFileName)}";

            Console.WriteLine($"... Writing test framework API frequencies to '{reportFile}'");


            string report = JsonSerializer.Serialize(AssemblyFrequencies.FromDictionary(testFrameworkAPIFrequencies),
                                                     GetJsonSerializerOptions());

            File.WriteAllText(reportFile, report);

            return(testFrameworkAPIFrequencies);
        }
コード例 #2
0
        /// <summary>
        /// Write the assembly frequencies in a JSON file.
        /// </summary>
        private static IDictionary <int, HashSet <string> > ReportAssemblyFrequencies(string path, Dictionary <string, int> assemblies)
        {
            var assemblyFrequencies = new SortedDictionary <int, HashSet <string> >();

            foreach (var kvp in assemblies)
            {
                if (!assemblyFrequencies.ContainsKey(kvp.Value))
                {
                    assemblyFrequencies.Add(kvp.Value, new HashSet <string>());
                }

                assemblyFrequencies[kvp.Value].Add(kvp.Key);
            }

            string reportFile = $"{Path.Combine(path, AssemblyFrequencies.FileName)}";

            Console.WriteLine($"... Writing assembly frequencies to '{reportFile}'");

            string report = JsonSerializer.Serialize(AssemblyFrequencies.FromDictionary(assemblyFrequencies),
                                                     GetJsonSerializerOptions());

            File.WriteAllText(reportFile, report);

            return(assemblyFrequencies);
        }