/// <summary>
        /// Gets the test case list with basic information
        /// </summary>
        /// <param name="resultFolder">The path to the result folder</param>
        /// <param name="captureFolder">The path to the capture folder</param>
        /// <returns>Returns the test case list with basic information</returns>
        private List <DataType.TestCase> GetTestCaseList(string resultFolder, string captureFolder)
        {
            List <DataType.TestCase> testCaseList = new List <DataType.TestCase>();

            if (!File.Exists(CaseCategoryFile))
            {
                GenerateCaseCategoryFile();
            }

            string sJSON = File.ReadAllText(CaseCategoryFile);
            Dictionary <string, List <string> > testCases = serializer.Deserialize <Dictionary <string, List <string> > >(sJSON);

            string[] txtfiles = Directory.GetFiles(resultFolder);
            foreach (var file in txtfiles)
            {
                string caseName = Path.GetFileNameWithoutExtension(file);
                int    i        = caseName.IndexOf('_');
                caseName = caseName.Substring(i + 1); // out the sort id
                i        = caseName.IndexOf('_');
                string caseStatus = caseName.Substring(0, i);
                caseName = caseName.Substring(i + 1);
                DataType.TestCase tc = new DataType.TestCase()
                {
                    Name      = caseName,
                    Result    = caseStatus,
                    ClassType = caseClass.ContainsKey(caseName) ? caseClass[caseName] : null,
                    Category  = testCases.ContainsKey(caseName) ? testCases[caseName] : null,
                };
                testCaseList.Add(tc);
            }
            return(testCaseList);
        }
        /// <summary>
        /// Gets the test case list with basic information
        /// </summary>
        /// <param name="resultFolder">The path to the result folder</param>
        /// <param name="captureFolder">The path to the capture folder</param>
        /// <param name="results">The dictionary containing all the test case results</param>
        /// <returns>Returns the test case list with basic information</returns>
        private List <DataType.TestCase> GetTestCaseList(string resultFolder, string captureFolder, ConcurrentDictionary <string, DataType.TestCaseDetail> results)
        {
            Dictionary <string, DataType.TestCase> testCases = new Dictionary <string, DataType.TestCase>();

            var txtfiles = Directory.GetFiles(resultFolder)
                           .Select(file => Path.GetFileNameWithoutExtension(file));

            // File name structure is {datetime}_{result}_{casename}.
            // So order them by name, they are also ordered by execution time.
            // Using casename as the key of dictionary, the new record will overwrite the old one.
            txtfiles = txtfiles.OrderBy(i => i);
            foreach (var file in txtfiles)
            {
                string caseName = file;
                int    i        = caseName.IndexOf('_');
                caseName = caseName.Substring(i + 1); // out the sort id
                i        = caseName.IndexOf('_');
                string caseStatus = caseName.Substring(0, i);
                caseName = caseName.Substring(i + 1);
                DataType.TestCase tc = new DataType.TestCase()
                {
                    Name      = caseName,
                    Result    = caseStatus,
                    ClassType = results.ContainsKey(caseName) ? results[caseName].ClassType : null,
                    Category  = results.ContainsKey(caseName) ? results[caseName].Categories : new List <string>(),
                };
                testCases[caseName] = tc; // overwrite the same case if any
            }

            List <DataType.TestCase> testCaseList = testCases.Values.OrderBy(tc => tc.Name).ToList(); // Sort by case name

            return(testCaseList);
        }
Пример #3
0
        /// <summary>
        /// Gets the test case list with basic information
        /// </summary>
        /// <param name="resultFolder">The path to the result folder</param>
        /// <param name="captureFolder">The path to the capture folder</param>
        /// <returns>Returns the test case list with basic information</returns>
        private List <DataType.TestCase> GetTestCaseList(string resultFolder, string captureFolder)
        {
            Dictionary <string, DataType.TestCase> testCases = new Dictionary <string, DataType.TestCase>();

            if (!File.Exists(CaseCategoryFile))
            {
                GenerateCaseCategoryFile();
            }

            string sJSON = File.ReadAllText(CaseCategoryFile);
            Dictionary <string, List <string> > testCaseToCategory = serializer.Deserialize <Dictionary <string, List <string> > >(sJSON);

            string[] txtfiles = Directory.GetFiles(resultFolder)
                                .Select(file => Path.GetFileNameWithoutExtension(file)).ToArray();

            // File name structure is {datetime}_{result}_{casename}.
            // So order them by name, they are also ordered by execution time.
            // Using casename as the key of dictionary, the new record will overwrite the old one.
            txtfiles = txtfiles.OrderBy(i => i).ToArray();
            foreach (var file in txtfiles)
            {
                string caseName = file;
                int    i        = caseName.IndexOf('_');
                caseName = caseName.Substring(i + 1); // out the sort id
                i        = caseName.IndexOf('_');
                string caseStatus = caseName.Substring(0, i);
                caseName = caseName.Substring(i + 1);
                DataType.TestCase tc = new DataType.TestCase()
                {
                    Name      = caseName,
                    Result    = caseStatus,
                    ClassType = caseClass.ContainsKey(caseName) ? caseClass[caseName] : null,
                    Category  = testCaseToCategory.ContainsKey(caseName) ? testCaseToCategory[caseName] : null,
                };
                testCases[caseName] = tc; // overwrite the same case if any
            }

            List <DataType.TestCase> testCaseList = testCases.Values.OrderBy(tc => tc.Name).ToList(); // Sort by case name

            return(testCaseList);
        }
        /// <summary>
        /// Gets the test case list with basic information
        /// </summary>
        /// <param name="resultFolder">The path to the result folder</param>
        /// <param name="captureFolder">The path to the capture folder</param>
        /// <param name="results">The dictionary containing all the test case results</param>
        /// <returns>Returns the test case list with basic information</returns>
        private List <DataType.TestCase> GetTestCaseList(ConcurrentDictionary <string, DataType.TestCaseDetail> results)
        {
            Dictionary <string, DataType.TestCase> testCases = new Dictionary <string, DataType.TestCase>();

            foreach (var kvp in results)
            {
                DataType.TestCase tc = new DataType.TestCase()
                {
                    FullyQualifiedName = kvp.Key,
                    Name      = kvp.Value.Name,
                    Result    = kvp.Value.Result,
                    ClassType = kvp.Value.ClassType,
                    Category  = kvp.Value.Categories,
                };
                testCases[kvp.Key] = tc; // overwrite the same case if any
            }

            List <DataType.TestCase> testCaseList = testCases.Values.OrderBy(tc => tc.Name).ToList(); // Sort by case name

            return(testCaseList);
        }
        /// <summary>
        /// Gets the test case list with basic information
        /// </summary>
        /// <param name="resultFolder">The path to the result folder</param>
        /// <param name="captureFolder">The path to the capture folder</param>
        /// <returns>Returns the test case list with basic information</returns>
        private List<DataType.TestCase> GetTestCaseList(string resultFolder, string captureFolder)
        {
            List<DataType.TestCase> testCaseList = new List<DataType.TestCase>();

            if (!File.Exists(CaseCategoryFile))
            {
                GenerateCaseCategoryFile();
            }

            string sJSON = File.ReadAllText(CaseCategoryFile);
            Dictionary<string, List<string>> testCases = serializer.Deserialize<Dictionary<string, List<string>>>(sJSON);
            string[] txtfiles = Directory.GetFiles(resultFolder);
            foreach (var file in txtfiles)
            {
                string caseName = Path.GetFileNameWithoutExtension(file);
                int i = caseName.IndexOf('_');
                caseName = caseName.Substring(i + 1); // out the sort id
                i = caseName.IndexOf('_');
                string caseStatus = caseName.Substring(0, i);
                caseName = caseName.Substring(i + 1);
                DataType.TestCase tc = new DataType.TestCase()
                {
                    Name = caseName,
                    Result = caseStatus,
                    ClassType = caseClass.ContainsKey(caseName) ? caseClass[caseName] : null,
                    Category = testCases.ContainsKey(caseName) ? testCases[caseName] : null,
                };
                testCaseList.Add(tc);
            }
            return testCaseList;
        }