public async Task EvaluateScores_ExpectScoreFormatterCalled() { var games = new List <TennisGame>(); new Fixture().AddManyTo(games, 10); _mockScoreReader.ReadFile(Arg.Any <string>()).Returns(games); _mockMatchCalculator.Calculate(Arg.Any <TennisGame>()).Returns(new Fixture().Create <TennisMatch>()); _mockScoreWriter.WriteFile(Arg.Any <string>(), Arg.Any <List <string> >()).Returns(true); await _sut.EvaluateScores("input", "output"); await _mockSetScoreFormatter .Received(games.Count) .Format(Arg.Any <TennisMatch>()); }
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); }