public IEnumerable <LineFeed> Process(EventSearchRequest eventSearchRequest) { _validationService.Validate(eventSearchRequest); if (!File.Exists(eventSearchRequest.FilePath)) { throw new FileNotFoundException($"{eventSearchRequest.FilePath} not found"); } var feeds = new ConcurrentBag <LineFeed>(); Parallel.ForEach( File.ReadLines(eventSearchRequest.FilePath), new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, (line, state, index) => { var entity = _recordService.ExtractLineFeed(line, eventSearchRequest.FeedSeparator, eventSearchRequest.StartDate, eventSearchRequest.EndDate); if (entity != null) { feeds.Add(entity); } } ); return(feeds); }
public void RecordService_Empty_Line() { var result = _recordService.ExtractLineFeed(string.Empty, ',', DateTime.Now, DateTime.Now); result.Should().BeNull(); }