コード例 #1
0
        public void ShouldDraw_DifferentCards_WhenCalledAgain()
        {
            //assign
            IRandom fakeRandom = new FakeRandom();

            List <ICard> startingDeck = new List <ICard>
            {
                new RedCard(), new GreenCard(), new BlueCard(),
                new RedCard(), new BlueCard(), new RedCard(), new GreenCard()
            };
            List <ICard> firstExpected = new List <ICard>
            {
                new RedCard(), new GreenCard(), new BlueCard(),
            };
            List <ICard> secondExpected = new List <ICard>
            {
                new RedCard(), new BlueCard(),
            };

            CardList cardList    = new CardList(startingDeck);
            IDeck    currentDeck = new DummyDeck(fakeRandom, cardList);
            //act
            List <ICard> firstDraw  = currentDeck.Draw(3);
            List <ICard> secondDraw = currentDeck.Draw(2);

            //assert
            firstExpected.ForEach(card => firstDraw.Should().ContainSingle(actualCard => actualCard.Matches(card)));
            secondExpected.ForEach(card => secondDraw.Should().ContainSingle(actualCard => actualCard.Matches(card)));
        }
コード例 #2
0
        public void ShouldShuffleCards()
        {
            //assign
            IRandom fakeRandom = new FakeRandom();

            List <ICard> startingDeck = new List <ICard>
            {
                new RedCard(), new GreenCard(), new BlueCard(),
                new RedCard(), new BlueCard(), new RedCard(), new GreenCard()
            };
            CardList cardList    = new CardList(startingDeck);
            IDeck    currentDeck = new DummyDeck(fakeRandom, cardList);
            //act
            List <ICard> firstDrawCards = currentDeck.Draw(7);

            //assert
            firstDrawCards.Should().ContainInOrder(startingDeck);

            IDeck shuffledDeck = currentDeck.Shuffle();

            shuffledDeck.Should().NotBe(startingDeck);
        }
コード例 #3
0
        public void ShouldDraw_Cards_WhenLessThanRequestedAmountExists()
        {
            //assign
            IRandom fakeRandom = new FakeRandom();

            List <ICard> startingDeck = new List <ICard>
            {
                new RedCard(), new GreenCard()
            };
            List <ICard> expectedReturn = new List <ICard>
            {
                new RedCard(), new GreenCard()
            };

            CardList cardList    = new CardList(startingDeck);
            IDeck    currentDeck = new DummyDeck(fakeRandom, cardList);
            //act
            List <ICard> drawnCards = currentDeck.Draw(5);

            //assert
            expectedReturn.ForEach(card => drawnCards.Should().ContainSingle(actualCard => actualCard.Matches(card)));
        }