public void AggregateReport_WhenOneReportItem_ReturnsOneGroupedIssueWithSameDescription()
        {
            var report = new Report();
            var issuesList = new List<Issue> { new Issue { IssueDescription = "Desc" } };
            report.Issues = issuesList;

            IEnumerable<IssueGrouped> groupedIssues = new CommandLineReportPrinter().AggregateReport(report);

            Assert.AreEqual("Desc", groupedIssues.ToList()[0].IssueDescription);
        }
        public void AggregateReport_WhenOneReportItemWithOneEntry_ReturnsOneGroupedIssueWithCountOne()
        {
            var report = new Report();
            var issuesList = new List<Issue> { new Issue { IssueDescription = "Desc" } };
            report.Issues = issuesList;

            IEnumerable<IssueGrouped> groupedIssues = new CommandLineReportPrinter().AggregateReport(report);

            Assert.AreEqual(1, groupedIssues.Count());
        }
        public void Print(Report report)
        {
            Console.WriteLine("Problems found:");

            var groupedIssues = AggregateReport(report);

            foreach (var issue in groupedIssues)
            {
                Console.WriteLine("{0} ({1})  {2}", issue.IssueDescription, issue.IssueCount, issue.RiskDescription);
            }
        }
        public IEnumerable<IssueGrouped> AggregateReport(Report report)
        {
            if (report != null)
            {
                return from issue in report.Issues
                       group issue by new { issue.IssueDescription, issue.RiskDescription } into groupedIssue
                       select new IssueGrouped
                       {
                           IssueDescription = groupedIssue.Key.IssueDescription,
                           RiskDescription = groupedIssue.Key.RiskDescription,
                           IssueCount = groupedIssue.Count()
                       };
            }

            return null;
        }
        public void AggregateReport_WhenTwoReportItemsWithTwoEntries_ReturnsTowGroupedIssuesWithCountTwo()
        {
            var report = new Report();
            var issuesList = new List<Issue>
                             {
                                 new Issue { IssueDescription = "Desc" },
                                 new Issue { IssueDescription = "Desc" },
                                 new Issue { IssueDescription = "Desc2" }
                             };
            report.Issues = issuesList;

            IEnumerable<IssueGrouped> groupedIssues = new CommandLineReportPrinter().AggregateReport(report);

            Assert.AreEqual(2, groupedIssues.ToList()[0].IssueCount);
            Assert.AreEqual(1, groupedIssues.ToList()[1].IssueCount);
        }
        public void AggregateReport_WhenTwoReportItems_ReturnsTwoGroupedIssues()
        {
            var report = new Report();
            var issuesList = new List<Issue>
                             {
                                 new Issue { IssueDescription = "Desc" },
                                 new Issue { IssueDescription = "Desc2" }
                             };
            report.Issues = issuesList;

            IEnumerable<IssueGrouped> groupedIssues = new CommandLineReportPrinter().AggregateReport(report);

            Assert.AreEqual(2, groupedIssues.Count());
        }