private void LegacyDbDumpReader_RecordsForDayRead(object sender, RecordsForDayReadEventArgs e)
        {
            loggingService.LogDebug($"Batch Read: {e.Records.First().Date} - {e.Records.Count()} record(s)");

            // Map the data
            var statsData = dataMappingService.MapData(e.Records);

            // Build filenames
            var filename   = $"FoldingStatsData-{e.Records.First().Date.ToString("yyyyMMdd")}.txt";
            var path       = fileSystemOperationsService.GetTempPath();
            var fullPath   = Path.Combine(path, filename);
            var targetPath = Path.Combine(outputPath, filename + fileCompressionService.FileExt);

            // Remove intermediate file, if it already exists
            DeleteFileIfExists(fullPath);

            // Write the data in stats file format
            statsDataWriter.Write(statsData, e.Records.First().Date, fullPath);

            try
            {
                // Compress the stats file
                var tempFile = fileSystemOperationsService.GetTempFilename();
                fileCompressionService.CompressFile(fullPath, tempFile);

                // Move to output folder
                fileSystemOperationsService.MoveFile(tempFile, targetPath);
            }
            finally
            {
                // Cleanup
                DeleteFileIfExists(fullPath);
            }
        }
        public void Execute_WhenLegacyReaderRecordsForDayReadFires_CompressesStatsFiles()
        {
            var outputRecords = new List <StatsDataItem>();

            outputRecords.Add(new StatsDataItem());
            var inputRecords = SetUpLegacyDataReader();

            dataMappingServiceMock.MapData(inputRecords).Returns(outputRecords);
            var outputFilename         = SetUpStatsFileIntermediateOutputFilename(inputRecords);
            var tempCompressedFilename = @"c:\path\to\tmp\tmpfile.tmp";

            fileSystemOperationsServiceMock.GetTempFilename().Returns(tempCompressedFilename);

            systemUnderTest.Execute(new[] { "arg1", "arg2" });

            fileCompressionServiceMock.Received(1).CompressFile(outputFilename, tempCompressedFilename);
        }