示例#1
0
        private Turn CreateTurnWithSpecificCards(IDice dice, IEnumerable <ICard> cards)
        {
            cardDeckFactory = new FakeCardDeckFactory(cards);
            var locationFactory = new TraditionalLocationFactory(banker, dice, jailRoster, board, cardDeckFactory);

            board.SetLocations(locationFactory.GetLocations(), locationFactory.GetRailroads(), locationFactory.GetUtilities());
            return(new NormalTurn(playerId, dice, jailRoster, board));
        }
示例#2
0
 public TraditionalLocationFactory(TraditionalBanker banker, IDice dice, 
     TraditionalJailRoster jailRoster, IBoard board,
     CardDeckFactory cardDeckFactory)
 {
     this.banker = banker;
     this.dice = dice;
     this.jailRoster = jailRoster;
     this.board = board;
     this.cardDeckFactory = cardDeckFactory;
 }
示例#3
0
        public void SetUp()
        {
            playerId        = 0;
            banker          = new TraditionalBanker(new[] { playerId });
            jailRoster      = new TraditionalJailRoster(banker);
            board           = new GameBoard(banker);
            cardDeckFactory = new FakeCardDeckFactory(CreateCards());
            var locationFactory = new TraditionalLocationFactory(banker, dice, jailRoster, board, cardDeckFactory);

            board.SetLocations(locationFactory.GetLocations(), locationFactory.GetRailroads(), locationFactory.GetUtilities());
        }
示例#4
0
        public void testCardUniqueness()
        {
            int         numberOfCards = 4 * 13;
            ISet <Card> cardSet       = new HashSet <Card>();
            var         cardDeck      = CardDeckFactory.Create();

            for (int i = 0; i < numberOfCards; i++)
            {
                cardSet.Add(cardDeck.DealOneCard());
            }

            Assert.AreEqual(cardSet.Count, numberOfCards);
        }
示例#5
0
        public void testCardUniquenessWithShuffle()
        {
            //Arrange
            IRandomNumberGenerator numberGenerator = new RandomNumberGenerator();
            int         numberOfCards = 4 * 13;
            ISet <Card> cardSet       = new HashSet <Card>();
            var         cardDeck      = CardDeckFactory.Create();

            //Act
            for (int i = 0; i < numberOfCards; i++)
            {
                cardDeck.Shuffle(numberGenerator);
                cardSet.Add(cardDeck.DealOneCard());
            }

            //Assert
            Assert.AreEqual(cardSet.Count, numberOfCards);
        }
示例#6
0
        public void testTwoDeckInOne()
        {
            //Arrange
            IRandomNumberGenerator numberGenerator = new RandomNumberGenerator();
            int         numberOfCards = 4 * 13;
            ISet <Card> cardSet       = new HashSet <Card>();
            var         cardDeck      = CardDeckFactory.Create();
            List <Card> twoDeckInOne  = new List <Card>(cardDeck.Cards);

            twoDeckInOne.AddRange(cardDeck.Cards);
            var twoCardDeck = new CardDeck(twoDeckInOne);

            //Act
            for (int i = 0; i < numberOfCards * 2; i++)
            {
                twoCardDeck.Shuffle(numberGenerator);
                cardSet.Add(twoCardDeck.DealOneCard());
            }

            //Assert
            Assert.AreEqual(cardSet.Count, numberOfCards);
        }