public void ShouldProcessTheFiles() { var filesTest = new List <string> { "Test.dat" }; var summaryResult = new SummaryResult { AmoutClients = 1, AmoutSalesman = 1, FileName = "Test.dat", IdExpensiveSale = "1a", WorstSalesman = "fulano" }; var fileProcessing = Path.Combine(PathConfigurations.RootPathProcessing, filesTest[0]); _fileManagementMock.Setup(x => x.Scanner()).Returns(filesTest); _fileManagementMock.Setup(x => x.MoveForProcessing(filesTest[0])).Returns(fileProcessing); var response = _fileProcessorMock.Setup(x => x.SummarizeFile(fileProcessing)).Returns(summaryResult); _fileManagementMock.Setup(x => x.SaveFile(summaryResult)); _fileProcessingService.ProcessFiles(); _fileManagementMock.Verify(x => x.Scanner(), Times.Once); _fileManagementMock.Verify(x => x.MoveForProcessing(filesTest[0]), Times.Once); _fileProcessorMock.Verify(x => x.SummarizeFile(fileProcessing), Times.Once); _fileManagementMock.Verify(x => x.SaveFile(summaryResult), Times.Once); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { while (!stoppingToken.IsCancellationRequested) { _fileProcessingService.ProcessFiles(); _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); await Task.Delay(1000, stoppingToken); } }