示例#1
0
        public async Task <ActionResult <DeckModel> > CreateAsync(DeckCreateModel model, CancellationToken cancellationToken)
        {
            var userId  = (await GetUserAsync(cancellationToken: cancellationToken)).Id;
            var newDeck = await _deckService.CreateDeckAsync(model, userId, cancellationToken : cancellationToken);

            return(CreatedAtAction(nameof(GetByIdAsync), new { id = newDeck.Id }, newDeck));
        }
示例#2
0
        public async Task <IActionResult> CreateNewDeck(int numberOfPlayers)
        {
            if (numberOfPlayers <= 1)
            {
                return(BadRequest("number of player should be greater than 1"));
            }

            var result = await _gameControlService.CreateDeckAsync(numberOfPlayers);

            return(Ok(new DeckResults(
                          deckId: result.DeckId,
                          shuffled: true,
                          playerTurn: result.PlayerTurn,
                          nPlayer: result.NPlayers,
                          remaining: result.Cards.Count())));
        }
        public async Task CreateDeckAsync_ShouldReturnNewDeck()
        {
            // Arrange
            var nPlayer = _fixture.Create <int>();

            _deckRepository
            .Setup(a => a.CreateAsync(It.IsAny <Deck>()))
            .Returns(Task.CompletedTask);

            // Act
            var result = await _deckService.CreateDeckAsync(nPlayer);

            // Assert
            result
            .Should()
            .NotBeNull();

            result
            .NPlayers
            .Should()
            .Be(nPlayer);
        }