예제 #1
0
        public static void CreateCttm(string emFilePath, string srcPath, string outputPath)
        {
            EmmaBinaryReader cebre = new EmmaBinaryReader(emFilePath);
            MetaDataDescriptor cedata = (MetaDataDescriptor)LoadEmmaFile(cebre);
            cebre.Close();
            Report.ReportDataModel current = new Report.ReportDataModel();
            Report.RootItem croot = current.CreateViewForDiff(cedata, srcPath);

            FileStream fs = new FileStream(outputPath, FileMode.OpenOrCreate);
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(fs, current);
            fs.Close();
            fs.Dispose();
        }
        public DiffItem Compare(ReportDataModel oldReportData)
        {
            HashSet<int> currentHash = new HashSet<int>();
            HashSet<int> currentHashForExpect = new HashSet<int>();
            HashSet<int> previousHash = new HashSet<int>();

            Dictionary<int, Dictionary<string, BlockItem>> currentBlocks = new Dictionary<int, Dictionary<string, BlockItem>>();
            Dictionary<int, Dictionary<string, BlockItem>> previousBlocks = new Dictionary<int, Dictionary<string, BlockItem>>();
            foreach (string key in oldReportData.ClassMap.Keys)
            {
                if (m_classMap.ContainsKey(key) && oldReportData.ClassMap[key].HashCode == m_classMap[key].HashCode)
                {
                    continue;
                }
                foreach (Item methodItem in oldReportData.ClassMap[key].Children)
                {
                    foreach (Item blockItem in methodItem.Children)
                    {
                        BlockItem block=blockItem as BlockItem;
                        int hash=block.HashCode;
                        previousHash.Add(hash);
                        if (!previousBlocks.ContainsKey(hash))
                        {
                            Dictionary<string, BlockItem> previousBlockMap = new Dictionary<string, BlockItem>();
                            previousBlockMap.Add(block.Name, block);
                            previousBlocks.Add(hash, previousBlockMap);
                        }
                        else
                        {
                            if (!previousBlocks[hash].ContainsKey(block.Name))
                            {
                                previousBlocks[hash].Add(block.Name, block);
                            }
                        }
                    }
                }
            }

            foreach (string key in m_classMap.Keys)
            {
                if (oldReportData.ClassMap.ContainsKey(key) && oldReportData.ClassMap[key].HashCode == m_classMap[key].HashCode)
                {
                    continue;
                }
                foreach (Item methodItem in m_classMap[key].Children)
                {
                    foreach (Item blockItem in methodItem.Children)
                    {
                        BlockItem block = blockItem as BlockItem;
                        int hash = block.HashCode;
                        currentHash.Add(hash);
                        currentHashForExpect.Add(hash);
                        if (!currentBlocks.ContainsKey(hash))
                        {
                            Dictionary<string, BlockItem> currentBlockMap = new Dictionary<string, BlockItem>();
                            currentBlockMap.Add(block.Name, block);
                            currentBlocks.Add(hash, currentBlockMap);
                        }
                        else
                        {
                            if (!currentBlocks[hash].ContainsKey(block.Name))
                            {
                                currentBlocks[hash].Add(block.Name, block);
                            }
                        }
                    }
                }
            }

            currentHash.ExceptWith(previousHash);
            previousHash.ExceptWith(currentHashForExpect);

            DiffItem diffItem = new DiffItem();

            foreach (int i in currentHash)
            {
                foreach (BlockItem item in currentBlocks[i].Values)
                {
                    diffItem.AddedBlocks.Add(item);
                }
            }

            foreach (int i in previousHash)
            {
                foreach (BlockItem item in previousBlocks[i].Values)
                {
                    diffItem.ReducedBlocks.Add(item);
                }
            }

            return diffItem;
        }
예제 #3
0
        private static ReportDataModel CreateModuleForCttr(string emFilePath, CttCaseCollection ecFilesPaths, string srcPath)
        {
            EmmaBinaryReader ebre = new EmmaBinaryReader(emFilePath);
            MetaDataDescriptor edata = (MetaDataDescriptor)LoadEmmaFile(ebre);
            ebre.Close();
            CaseCoverageDescriptor ccdata = new CaseCoverageDescriptor();

            foreach (CttCase cttCase in ecFilesPaths.CoverageFilePaths)
            {
                EmmaBinaryReader ebrc = new EmmaBinaryReader(cttCase.ResultPath);
                CoverageDataDescriptor cdata = (CoverageDataDescriptor)LoadEmmaFile(ebrc);
                ebrc.Close();

                ccdata.MergeCaseCoverageData(cdata, cttCase.CaseId);
            }

            ReportDataModel previous = new Report.ReportDataModel();
            RootItem root = previous.CreateViewForCaseCoverage(edata, ccdata, srcPath);
            return previous;
        }