Exemplo n.º 1
0
 public void TestMethod1()
 {
     var coverageSession = new CoverageSession();
     serializer.Serialize(writer,coverageSession);
     string result = textWriter.ToString();
     var expected = "<<?xml version=\"1.0\" encoding=\"utf-16\"?><CoverageSession xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" />>";
     Assert.AreEqual(expected,result);
 }
Exemplo n.º 2
0
 public void OneEmptyModule()
 {
     var coverageSession = new CoverageSession();
     coverageSession.Modules.Add(new Module());
     serializer.Serialize(writer, coverageSession);
     string result = textWriter.ToString();
     var expected =
         "<?xml version=\"1.0\" encoding=\"utf-16\"?><CoverageSession xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Modules><Module skippedDueTo=\"Filter\" /></Modules></CoverageSession>";
     Assert.AreEqual(expected, result);
 }
Exemplo n.º 3
0
 public void EmptySummary2()
 {
     var coverageSession = new CoverageSession();
     serializer = new XmlSerializer(typeof (Summary));
     var summary = new Summary(null);
     serializer.Serialize(writer, summary);
     string result = textWriter.ToString();
     var expected =
         "<Summary xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" numSequencePoints=\"0\" visitedSequencePoints=\"0\" nuumBranchPoints=\"0\" visitedBranchPoints=\"0\" sequenceCoverage=\"0\" branchCoverage=\"0\" maxCyclomaticComplexity=\"0\" numCyclomaticComplexity=\"0\" />";
     Assert.AreEqual(expected, result);
 }
Exemplo n.º 4
0
        private void Fun()
        {
            using (CoverageInfo info = CoverageInfo.CreateFromFile("foo.coverage"))
            {
                CoverageDS dataSet = info.BuildDataSet();
                dataSet.ExportXml("hi");
                List<BlockLineRange> lines = new List<BlockLineRange>();
                CoverageSession coverageSesson = new CoverageSession();

                foreach (ICoverageModule coverageModule in info.Modules)
                {
                    Module modelModule = new Module();
                    coverageSesson.Modules.Add(modelModule);
                    modelModule.FullName = coverageModule.Name;

                    byte[] coverageBuffer = coverageModule.GetCoverageBuffer(null);
                    using (ISymbolReader reader = coverageModule.Symbols.CreateReader())
                    {
                        uint methodId;
                        string methodName;
                        string undecoratedMethodName;
                        string className;
                        string namespaceName;

                        lines.Clear();
                        while (reader.GetNextMethod(out methodId, out methodName, out undecoratedMethodName, out className, out namespaceName, lines))
                        {
                            DumpLines(null,lines);
                            var modelClass=modelModule.FindClassByName(className);
                            var modelMethod = Method.Create(null);
                            modelClass.Methods.Add(modelMethod);

                            CoverageStatistics stats = CoverageInfo.GetMethodStatistics(coverageBuffer, lines);

                            Console.WriteLine("Method {0}{1}{2}{3}{4} has:",
                                namespaceName == null ? "" : namespaceName,
                                string.IsNullOrEmpty(namespaceName) ? "" : ".",
                                className == null ? "" : className,
                                string.IsNullOrEmpty(className) ? "" : ".",
                                methodName
                                );

                            Console.WriteLine("    {0} blocks covered", stats.BlocksCovered);
                            Console.WriteLine("    {0} blocks not covered", stats.BlocksNotCovered);
                            Console.WriteLine("    {0} lines covered", stats.LinesCovered);
                            Console.WriteLine("    {0} lines partially covered", stats.LinesPartiallyCovered);
                            Console.WriteLine("    {0} lines not covered", stats.LinesNotCovered);
                            lines.Clear();
                        }
                    }
                }
            }
        }