Exemple #1
0
        public void CanExportReport()
        {
            var projectReport = new ProjectReport();

            projectReport.AddIssue(new ProjectIssue
                                   (
                                       new ProblemDescriptor
            {
                area     = "CPU",
                type     = "SomeType",
                method   = "SomeMethod",
                problem  = "",
                solution = ""
            },
                                       "dummy issue",
                                       IssueCategory.ApiCalls
                                   ));
            projectReport.AddIssue(new ProjectIssue
                                   (
                                       new ProblemDescriptor
            {
                area     = "CPU",
                type     = "SomeType",
                method   = "SomeMethod",
                problem  = "",
                solution = ""
            },
                                       "dummy issue #2",
                                       IssueCategory.ProjectSettings
                                   ));

            const string path = "ProjectAuditor_Report.csv";

            projectReport.Export(path);
            Assert.True(File.Exists(path));

            string line;

            System.IO.StreamReader file = new System.IO.StreamReader(path);

            line = file.ReadLine();
            Assert.True(line.Equals("Issue,Area,Path,Line"));

            file.Close();
        }
Exemple #2
0
        public void IssueIsAddedToReport()
        {
            var projectReport = new ProjectReport();

            projectReport.AddIssue(new ProjectIssue
                                   (
                                       new ProblemDescriptor(),
                                       "dummy issue",
                                       IssueCategory.ApiCalls
                                   )
                                   );

            Assert.AreEqual(1, projectReport.NumTotalIssues);
            Assert.AreEqual(1, projectReport.GetNumIssues(IssueCategory.ApiCalls));
            Assert.AreEqual(0, projectReport.GetNumIssues(IssueCategory.ProjectSettings));
        }
        void Analyze()
        {
            m_AnalyzeButtonAnalytic = ProjectAuditorAnalytics.BeginAnalytic();

            m_ShouldRefresh = true;
            m_AnalysisState = AnalysisState.InProgress;
            m_ProjectReport = new ProjectReport();
            foreach (var view in m_AnalysisViews)
            {
                view.Clear();
            }

            var newIssues = new List <ProjectIssue>();

            try
            {
                m_ProjectAuditor.Audit(projectIssue =>
                {
                    newIssues.Add(projectIssue);
                    m_ProjectReport.AddIssue(projectIssue);
                },
                                       completed =>
                {
                    // add batch of issues
                    foreach (var view in m_AnalysisViews)
                    {
                        view.AddIssues(newIssues);
                    }

                    newIssues.Clear();

                    if (completed)
                    {
                        m_AnalysisState = AnalysisState.Completed;
                    }

                    m_ShouldRefresh = true;
                },
                                       new ProgressBarDisplay());
            }
            catch (AssemblyCompilationException e)
            {
                m_AnalysisState = AnalysisState.NotStarted;
                Debug.LogError(e);
            }
        }
        void Analyze()
        {
            m_AnalyzeButtonAnalytic = ProjectAuditorAnalytics.BeginAnalytic();

            m_ShouldRefresh = true;
            m_AnalysisState = AnalysisState.InProgress;
            m_ProjectReport = new ProjectReport();
            foreach (var view in m_Views)
            {
                if (view != null)
                {
                    view.Clear();
                }
            }

            AnalysisView.SetReport(m_ProjectReport);

            var newIssues = new List <ProjectIssue>();

            m_ProjectAuditor.Audit(projectIssue =>
            {
                newIssues.Add(projectIssue);
                m_ProjectReport.AddIssue(projectIssue);
            },
                                   completed =>
            {
                // add batch of issues
                foreach (var view in m_Views)
                {
                    if (view != null)
                    {
                        view.AddIssues(newIssues);
                    }
                }
                newIssues.Clear();

                if (completed)
                {
                    m_AnalysisState = AnalysisState.Completed;
                }

                m_ShouldRefresh = true;
            },
                                   new ProgressBarDisplay()
                                   );
        }
Exemple #5
0
        public void IssueIsAddedToReport()
        {
            var projectReport = new ProjectReport();
            var p             = new ProblemDescriptor
                                (
                102001,
                "test",
                Area.CPU,
                "this is not actually a problem",
                "do nothing"
                                );

            projectReport.AddIssue(new ProjectIssue
                                   (
                                       p,
                                       "dummy issue",
                                       IssueCategory.Code
                                   )
                                   );

            Assert.AreEqual(1, projectReport.NumTotalIssues);
            Assert.AreEqual(1, projectReport.GetNumIssues(IssueCategory.Code));
            Assert.AreEqual(0, projectReport.GetNumIssues(IssueCategory.ProjectSettings));
        }
        List <ProjectIssue> Audit <T>() where T : class, IAuditor
        {
            var auditor = m_ProjectAuditor.GetAuditor <T>();
            var layouts = auditor.GetLayouts().ToArray();

            foreach (var layout in layouts)
            {
                m_ProjectReport.ClearIssues(layout.category);
            }

            var newIssues = new List <ProjectIssue>();

            auditor.Audit(issue =>
            {
                newIssues.Add(issue);
                m_ProjectReport.AddIssue(issue);
            },
                          () =>
            {
            },
                          new ProgressBarDisplay()
                          );

            // update views
            var categories = layouts.Select(l => l.category);
            var views      = m_Views.Where(v => v != null && categories.Contains(v.desc.category));

            foreach (var view in views)
            {
                view.Clear();
                view.AddIssues(newIssues);
                view.Refresh();
            }

            return(newIssues);
        }