private static void AddTestToTestSuite(IEnumerable <IArkadeTest> tests, TestSuite testSuite) { foreach (var test in tests) { testSuite.AddTestRun(test.GetTestRun()); } }
public void FindNumberOfErrorsShouldReturnOneError() { var testSuite = new TestSuite(); var testRun = new TestRun("test with error", TestType.ContentAnalysis); testRun.Add(new TestResult(ResultType.Error, new Location(""), "feil")); testSuite.AddTestRun(testRun); testSuite.FindNumberOfErrors().Should().Be(1); }
public TestSuite GetTestSuite() { var testSuite = new TestSuite(); foreach (IAddmlProcess addmlProcess in _processManager.GetAllProcesses()) { testSuite.AddTestRun(addmlProcess.GetTestRun()); } return(testSuite); }
public TestSession Build() { if (_archive == null) { _archive = new ArchiveBuilder().WithArchiveType(ArchiveType.Noark3).Build(); } var testSession = new TestSession(_archive); foreach (var logEntry in _logEntries) { testSession.AddLogEntry(logEntry); } TestSuite testSuite = new TestSuite(); if (_testRuns.Count != 0) { foreach (var testRun in _testRuns) { testSuite.AddTestRun(testRun); } } else { testSuite.AddTestRun(new TestRunBuilder().Build()); } testSession.TestSuite = testSuite; if (_testSummary == null) { _testSummary = new TestSummary(0, 0, 0); } testSession.TestSummary = _testSummary; return(testSession); }
private static TestSuite CreateTestSuite(params TestResult[] testResults) { var testSuite = new TestSuite(); var testRun = new TestRun("test with error", TestType.ContentAnalysis); if (testResults != null) { foreach (var testResult in testResults) { testRun.Add(testResult); } } testSuite.AddTestRun(testRun); return(testSuite); }
public TestSuite GetTestSuite() { var testSuite = new TestSuite(); foreach (IAddmlProcess addmlProcess in _processManager.GetAllProcesses()) { // ControlForeignKey needs to access results of CollectPrimaryKey process // Consider moving this to ProcessManager.InstantiateProcesses() if (addmlProcess.GetType() == typeof(A_16_ControlForeignKey)) { LoadCollectedPrimaryKeysIntoControlForeignKeyProcess(addmlProcess); } // CollectPrimaryKey is internal and should not be part of the test report if (addmlProcess.GetType() != typeof(AI_01_CollectPrimaryKey)) { testSuite.AddTestRun(addmlProcess.GetTestRun()); } } return(testSuite); }
public TestSuite RunTestsOnArchive(TestSession testSession) { AddmlDefinition addmlDefinition = testSession.AddmlDefinition; _addmlProcessRunner.Init(addmlDefinition); List <FlatFile> flatFiles = addmlDefinition.GetFlatFiles(); foreach (FlatFile file in flatFiles) { string testName = string.Format(Messages.RunningAddmlProcessesOnFile, file.GetName()); var recordIdx = 1; _statusEventHandler.RaiseEventFileProcessingStarted( new FileProcessingStatusEventArgs(testName, file.GetName()) ); _addmlProcessRunner.RunProcesses(file); IRecordEnumerator recordEnumerator = _flatFileReaderFactory.GetRecordEnumerator(testSession.Archive, file); int numberOfRecordsWithFieldDelimiterError = 0; while (recordEnumerator != null && recordEnumerator.MoveNext()) { try { _statusEventHandler.RaiseEventRecordProcessingStart(); Record record = recordEnumerator.Current; _addmlProcessRunner.RunProcesses(file, record); foreach (Field field in record.Fields) { _addmlProcessRunner.RunProcesses(file, field); } } catch (ArkadeAddmlDelimiterException exception) { numberOfRecordsWithFieldDelimiterError++; if (numberOfRecordsWithFieldDelimiterError <= MaxNumberOfSingleReportedFieldDelimiterErrors) { _testResultsFailedRecordsList.Add(new TestResult(ResultType.Error, new AddmlLocation(file.GetName(), exception.RecordName, ""), exception.Message + " Felttekst: " + exception.RecordData) ); _statusEventHandler.RaiseEventOperationMessage( $"{AddmlMessages.RecordLengthErrorTestName} i fil {file.GetName()}, post nummer {recordIdx}, feil nummer {numberOfRecordsWithFieldDelimiterError}", exception.Message + " Felttekst: " + exception.RecordData, OperationMessageStatus.Error ); } else { _statusEventHandler.RaiseEventOperationMessage( $"ADDML-poster med feil antall felt i filen {file.GetName()}", $"Totalt antall: {numberOfRecordsWithFieldDelimiterError}", OperationMessageStatus.Error ); } } finally { _statusEventHandler.RaiseEventRecordProcessingStopped(); } recordIdx++; } if (numberOfRecordsWithFieldDelimiterError > 0) { _testResultsFailedRecordsList.Add(new TestResult(ResultType.ErrorGroup, new Location(file.GetName()), $"Filens totale antall poster med feil antall felt: {numberOfRecordsWithFieldDelimiterError}", numberOfRecordsWithFieldDelimiterError) ); } _addmlProcessRunner.EndOfFile(file); _statusEventHandler.RaiseEventFileProcessingFinished( new FileProcessingStatusEventArgs(testName, file.GetName(), true) ); } TestSuite testSuite = _addmlProcessRunner.GetTestSuite(); testSuite.AddTestRun(new AH_02_ControlExtraOrMissingFiles(addmlDefinition, testSession.Archive).GetTestRun()); testSuite.AddTestRun(new AH_03_ControlRecordAndFieldDelimiters(_testResultsFailedRecordsList).GetTestRun()); return(testSuite); }