Ejemplo n.º 1
0
        public String Execute(ProjectElement project)
        {
            StringBuilder buffer = new StringBuilder();

            buffer.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            buffer.Append(String.Format("\n<coverage generated=\"{0}\" clover=\"3.0.2\" xmlns=\"http://schemas.atlassian.com/clover3/report\">", project.Timestamp));
            buffer.Append(String.Format("\n<project name=\"{0}\" timestamp=\"{1}\">", project.Name, project.Timestamp));
            buffer.Append(String.Format("\n  {0}", project.Metrics.ToXml()));

            foreach (PackageElement pe in project.GetPackages())
            {
                buffer.Append(String.Format("\n  <package name=\"{0}\">", pe.Name));
                buffer.Append(String.Format("\n    {0}", pe.Metrics.ToXml()));
                foreach (FileElement fe in pe.GetFiles())
                {
                    buffer.Append(String.Format("\n    <file name=\"{0}\" path=\"{1}\">", fe.Name, fe.Path));
                    buffer.Append(String.Format("\n      {0}", fe.Metrics.ToXml()));
                    foreach (ClassElement ce in fe.GetClasses())
                    {
                        buffer.Append(String.Format("\n      <class name=\"{0}\">", ce.Name));
                        buffer.Append(String.Format("\n        {0}", ce.Metrics.ToXml()));
                        buffer.Append("\n      </class>");
                    }

                    foreach (LineElement le in fe.GetLines())
                    {
                        int visits = le.Coverage < 2 ? 1 : 0;
                        buffer.Append(String.Format("\n      <line num=\"{0}\" count=\"{1}\" type=\"{2}\"", le.Number, visits, le.Type));
                        if (le.Signature != null && le.Signature.Length > 0)
                        {
                            buffer.Append(String.Format(" signature=\"{0}\"", le.Signature));
                        }
                        buffer.Append(" />");
                    }
                    buffer.Append("\n    </file>");
                }
                buffer.Append("\n  </package>");
            }
            buffer.Append("</project>");
            buffer.Append("</coverage>");

            return(buffer.ToString());
        }
Ejemplo n.º 2
0
        public void DirectWrite(StreamWriter outfile, ProjectElement project, bool shortReport)
        {
            outfile.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            outfile.Write(String.Format("\n<coverage generated=\"{0}\" clover=\"3.0.2\" xmlns=\"http://schemas.atlassian.com/clover3/report\">", project.Timestamp));
            outfile.Write(String.Format("\n<project name=\"{0}\" timestamp=\"{1}\">", project.Name, project.Timestamp));
            outfile.Write(String.Format("\n  {0}", project.Metrics.ToXml()));

            foreach (PackageElement pe in project.GetPackages())
            {
                outfile.Write(String.Format("\n  <package name=\"{0}\">", pe.Name));
                outfile.Write(String.Format("\n    {0}", pe.Metrics.ToXml()));
                foreach (FileElement fe in pe.GetFiles())
                {
                    outfile.Write(String.Format("\n    <file name=\"{0}\" path=\"{1}\">", fe.Name, fe.Path));
                    outfile.Write(String.Format("\n      {0}", fe.Metrics.ToXml()));
                    if (!shortReport)
                    {
                        foreach (ClassElement ce in fe.GetClasses())
                        {
                            outfile.Write(String.Format("\n      <class name=\"{0}\">", ce.Name));
                            outfile.Write(String.Format("\n        {0}", ce.Metrics.ToXml()));
                            outfile.Write("\n      </class>");
                        }

                        foreach (LineElement le in fe.GetLines())
                        {
                            int visits = le.Coverage < 2 ? 1 : 0;
                            outfile.Write(String.Format("\n      <line num=\"{0}\" count=\"{1}\" type=\"{2}\"", le.Number, visits, le.Type));
                            if (le.Signature != null && le.Signature.Length > 0)
                            {
                                outfile.Write(String.Format(" signature=\"{0}\"", le.Signature));
                            }
                            outfile.Write(" />");
                        }
                    }
                    outfile.Write("\n    </file>");
                }
                outfile.Write("\n  </package>");
            }
            outfile.Write("</project>");
            outfile.Write("</coverage>");
        }
Ejemplo n.º 3
0
        public virtual String Execute(ProjectElement project)
        {
            StringBuilder buffer = new StringBuilder();

            Int32 timestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;

            buffer.Append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
            buffer.Append(String.Format("\n<coverage generated=\"{0}\" clover=\"3.0.2\" xmlns=\"http://schemas.atlassian.com/clover3/report\">", timestamp));
            buffer.Append(String.Format("\n<project name=\"\" timestamp=\"{0}\">", timestamp));
            buffer.Append(String.Format("\n  {0}", project.Metrics.ToXml()));

            foreach (PackageElement pe in project.GetPackages())
            {
                buffer.Append(String.Format("\n  <package name=\"{0}\">", System.Security.SecurityElement.Escape(pe.Name)));
                buffer.Append(String.Format("\n    {0}", pe.Metrics.ToXml()));

                foreach (ClassElement ce in pe.GetClasses())
                {
                    buffer.Append(String.Format("\n    <class name=\"{0}\">", System.Security.SecurityElement.Escape(ce.Name)));
                    buffer.Append(String.Format("\n      {0}", ce.Metrics.ToXml()));

                    foreach (MethodElement me in ce.GetMethods())
                    {
                        buffer.Append(String.Format("\n      <method name=\"{0}\">", System.Security.SecurityElement.Escape(me.Name)));
                        buffer.Append(String.Format("\n        {0}", me.Metrics.ToXml()));
                        buffer.Append("\n      </method>");
                    }
                    buffer.Append("\n    </class>");
                }
                buffer.Append("\n  </package>");
            }
            buffer.Append("</project>");
            buffer.Append("</coverage>");

            return(buffer.ToString());
        }