public async Task <bool> EvaluateScores(string inputFileLocation, string outputFileLocation) { var succeeded = true; var readerResult = await _scoreReader.ReadFile(inputFileLocation); if (readerResult.Count > 0) { var formattedMatches = new List <string>(); foreach (var match in readerResult) { var calculatedMatch = await _matchCalculator.Calculate(match); var formattedMatch = await _setScoreFormatter.Format(calculatedMatch); formattedMatches.Add(formattedMatch); } var writerSucceeded = await _scoreWriter.WriteFile(outputFileLocation, formattedMatches); if (!writerSucceeded) { succeeded = false; } } else { succeeded = false; } return(succeeded); }
public async Task EvaluateScores_ExpectScoreReaderCalled() { var inputPath = "input"; _mockScoreReader.ReadFile(inputPath).Returns(new Fixture().Create <List <TennisGame> >()); _mockScoreWriter.WriteFile(Arg.Any <string>(), Arg.Any <List <string> >()).Returns(true); await _sut.EvaluateScores(inputPath, "output"); await _mockScoreReader .Received(1) .ReadFile(inputPath); }