<commit_before>﻿using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Arkivverket.Arkade.Core.Base;

namespace Arkivverket.Arkade.Core.Report
{
    public static class TestReportFactory
    {
        public static TestReport Create(TestSession testSession)
        {
            var testReport = new TestReport
            {
                Summary = CreateTestReportSummary(testSession),
                TestsResults = GetTestReportResults(testSession),
            };

            return testReport;
        }

        private static TestReportSummary CreateTestReportSummary(TestSession testSession)
        {
            var norwegianCulture = new CultureInfo("nb-NO");
            int numberOfExecutedTests = testSession.TestSuite.TestRuns.Count();
            int numberOfAvailableTests = testSession.AvailableTests.Count;

            var summary = new TestReportSummary
            {
                Uuid = testSession.Archive.Uuid.ToString(),
                ArchiveCreators = testSession.Archive.Details.ArchiveCreators,
                ArchivalPeriod = testSession.Archive.Details.ArchivalPeriod,
                SystemName = testSession.Archive.Details.SystemName,
                SystemType = testSession.Archive.Details.SystemType,
                ArchiveType = testSession.Archive.ArchiveType,
                DateOfTesting = testSession.DateOfTesting.ToString(Resources.Report.DateFormat, norwegianCulture),
                NumberOfTestsRun = string.Format(Resources.Report.ValueNumberOfTestsExecuted, numberOfExecutedTests, numberOfAvailableTests),
                NumberOfProcessedFiles = testSession.TestSummary.NumberOfProcessedFiles,
                NumberOfProcessedRecords = testSession.TestSummary.NumberOfProcessedRecords,
                NumberOfErrors = testSession.TestSuite.FindNumberOfErrors().ToString(),
            };

            return summary;
        }

        private static List<ExecutedTest> GetTestReportResults(TestSession testSession)
        {
            var results = new List<ExecutedTest>();
<commit_msg>Fix bug caused by CLI not counting number of processed files and records<commit_after>﻿using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Arkivverket.Arkade.Core.Base;

namespace Arkivverket.Arkade.Core.Report
{
    public static class TestReportFactory
    {
        public static TestReport Create(TestSession testSession)
        {
            var testReport = new TestReport
            {
                Summary = CreateTestReportSummary(testSession),
                TestsResults = GetTestReportResults(testSession),
            };

            return testReport;
        }

        private static TestReportSummary CreateTestReportSummary(TestSession testSession)
        {
            var norwegianCulture = new CultureInfo("nb-NO");
            int numberOfExecutedTests = testSession.TestSuite.TestRuns.Count();
            int numberOfAvailableTests = testSession.AvailableTests.Count;

            var summary = new TestReportSummary
            {
                Uuid = testSession.Archive.Uuid.ToString(),
                ArchiveCreators = testSession.Archive.Details.ArchiveCreators,
                ArchivalPeriod = testSession.Archive.Details.ArchivalPeriod,
                SystemName = testSession.Archive.Details.SystemName,
                SystemType = testSession.Archive.Details.SystemType,
                ArchiveType = testSession.Archive.ArchiveType,
                DateOfTesting = testSession.DateOfTesting.ToString(Resources.Report.DateFormat, norwegianCulture),
                NumberOfTestsRun = string.Format(Resources.Report.ValueNumberOfTestsExecuted, numberOfExecutedTests, numberOfAvailableTests),
                NumberOfErrors = testSession.TestSuite.FindNumberOfErrors().ToString(),
            };

            if (testSession.TestSummary != null)
            {
                summary.NumberOfProcessedFiles = testSession.TestSummary.NumberOfProcessedFiles;
                summary.NumberOfProcessedRecords = testSession.TestSummary.NumberOfProcessedRecords;
            }

            return summary;
        }

        private static List<ExecutedTest> GetTestReportResults(TestSession testSession)
        {
            var results = new List<ExecutedTest>();

{'fraction_non_alphanumeric': 0.06728323699421965, 'fraction_numerical': 0.0, 'mean_word_length': 2.485898468976632, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5447730', 'n_tokens_mistral': 1053, 'n_tokens_neox': 992, 'n_words': 183}