예제 #1
0
        public async Task <GameStarted> StartGame(int nbrOfRounds, CancellationToken cancellationToken = default)
        {
            if (nbrOfRounds <= 0)
            {
                throw new ValidationException("Number of rounds must be 1 or higher.");
            }

            var truth = new Dictionary <int, int>();

            for (var round = 1; round <= nbrOfRounds; round++)
            {
                cancellationToken.ThrowIfCancellationRequested();
                truth.Add(round, _randomizer.Randomize());
            }

            await _repository.Initialize(truth, cancellationToken);

            return(GameStarted.Start(nbrOfRounds));
        }