Ejemplo n.º 1
0
        public void When_Player_Buys_Card_With_Wrong_Id_Then_NoEntityFoundException()
        {
            var generatedCards = 6;
            var testCards      = StubCard.GenerateCards(generatedCards);
            var board          = new GameBoard(testCards);
            var player         = new Player(board);

            var boughtCardId = Guid.NewGuid();

            Assert.Throws <NoEntityFoundWithIdException <Card> >(() => player.BuyCard(boughtCardId));
        }
Ejemplo n.º 2
0
        public void Given_Board_With_Cards_When_Player_Buys_First_Card_Then_Card_Is_Transferred()
        {
            var testCards = StubCard.GenerateCards(10);
            var board     = new GameBoard(testCards);
            var player    = new Player(board);

            var boughtCardId = board.AvailableTrades.ElementAt(0).Card.Id;

            player.BuyCard(boughtCardId);

            Assert.Contains(boughtCardId, player.Hand.Cards.Select(x => x.Id));
            Assert.DoesNotContain(boughtCardId, board.AvailableTrades.Select(x => x.Card.Id));
        }
Ejemplo n.º 3
0
        public void Given_Board_With_Insufficient_Cards_When_Player_Buys_First_Card_Then_Fewer_Available_Cards()
        {
            var generatedCards    = 6;
            var expectedCardCount = generatedCards - 1;
            var testCards         = StubCard.GenerateCards(generatedCards);
            var board             = new GameBoard(testCards);
            var player            = new Player(board);

            var boughtCardId = board.AvailableTrades.ElementAt(0).Card.Id;

            player.BuyCard(boughtCardId);


            Assert.Equal(expectedCardCount, board.AvailableTrades.Count());
        }
Ejemplo n.º 4
0
        public void Given_Player_Buys_Cards_By_Id_When_Offer_Does_Not_Match_Then_InvalidTradeOfferException()
        {
            var generatedCards = 10;
            var testCards      = StubCard.GenerateCards(generatedCards);
            var board          = new GameBoard(testCards);
            var player         = new Player(board);
            var buyIndex       = 3;
            var boughtCardId   = board.AvailableTrades.ElementAt(buyIndex).Card.Id;

            Assert.Throws <InvalidTradeOfferException>(() =>
                                                       player.BuyCard(
                                                           boughtCardId,
                                                           new TradeOffer(
                                                               Resource.Tumeric,
                                                               Resource.Cardemom
                                                               )
                                                           )
                                                       );
        }