コード例 #1
0
        public void StandardFaceCardValueIsCorrectlyDeserialized()
        {
            //Arrange
            CardDeckConfiguration configuration;
            int faceCardValue = 10;

            //Act
            configuration = new CardDeckConfigurationProvider().GetRules();

            //Assert
            if (configuration.FaceCardValue != faceCardValue)
            {
                string errorMessage = $"The value acquired for the face card value is wrong! Excepted value is: {faceCardValue}. Acquired value is: {configuration.FaceCardValue}";
                Assert.Fail(errorMessage);
            }
        }
コード例 #2
0
        public void StandardSmallestValueOfNumericalCardsIsCorrectlyDeserialized()
        {
            //Arrange
            CardDeckConfiguration configuration;
            int smallestValueOfNumericalCards = 2;

            //Act
            configuration = new CardDeckConfigurationProvider().GetRules();

            //Assert
            if (configuration.SmallestValueOfNumericalCards != smallestValueOfNumericalCards)
            {
                string errorMessage =
                    $"The value acquired for the smallest value of numerical cards is wrong! Excepted value is: {smallestValueOfNumericalCards}. Acquired value is: {configuration.SmallestValueOfNumericalCards}";
                Assert.Fail(errorMessage);
            }
        }
コード例 #3
0
        public void StandardNumberOfNumericalCardsInASuitIsCorrectlyDeserialized()
        {
            //Arrange
            CardDeckConfiguration configuration;
            int numberOfNumericalCardsInASuit = 9;

            //Act
            configuration = new CardDeckConfigurationProvider().GetRules();

            //Assert
            if (configuration.NumberOfNumericalCardsInASuit != numberOfNumericalCardsInASuit)
            {
                string errorMessage =
                    $"The value acquired for the number of numerical cards in a suit is wrong! Excepted value is: {numberOfNumericalCardsInASuit}. Acquired value is: {configuration.NumberOfNumericalCardsInASuit}";
                Assert.Fail(errorMessage);
            }
        }
コード例 #4
0
        public void CardDeckHasCorrectNumberOfCards()
        {
            //Arrange
            CardDeckConfiguration configuration = new CardDeckConfigurationProvider().GetRules();
            //by default it is 13x4 = 52
            int       numberOfExpectedCards = configuration.NumberOfCardsInASuit * configuration.CardSuits.Count;
            ICardDeck cardDeck;

            //Act
            cardDeck = new CardDeck();

            //Assert
            if (cardDeck.Cards.Count != numberOfExpectedCards)
            {
                string errorMessage = $"Created card deck does not have expected number of cards. Expected number is {numberOfExpectedCards}. Actual number of cards is {cardDeck.Cards.Count}";
                Assert.Fail(errorMessage);
            }
        }
コード例 #5
0
        public void CardDeckHasCorrectSuits()
        {
            //Arrange
            CardDeckConfiguration configuration = new CardDeckConfigurationProvider().GetRules();
            //by default four suits: Clubs, Diamonds, Hearts, Spades
            List <ECardSuitTypes> expectedCardSuits = configuration.CardSuits;
            ICardDeck             cardDeck;

            //Act
            cardDeck = new CardDeck();
            List <ECardSuitTypes> suitTypes = GetCardSuitTypesFromDeck(cardDeck);

            //Assert
            if (suitTypes.Count != expectedCardSuits.Count && expectedCardSuits.Any(t => !suitTypes.Contains(t)))
            {
                string errorMessage = "Created card deck does not contain all expected suit types!";
                Assert.Fail(errorMessage);
            }
        }
コード例 #6
0
        public void CardSuitTypesIsCorrectlyDeserialized()
        {
            //Arrange
            CardDeckConfiguration configuration;

            ECardSuitTypes[] cardSuitTypes =
            {
                ECardSuitTypes.Clubs,
                ECardSuitTypes.Diamonds,
                ECardSuitTypes.Hearts,
                ECardSuitTypes.Spades
            };

            //Act
            configuration = new CardDeckConfigurationProvider().GetRules();

            //Assert
            if (configuration.CardSuits.Count != cardSuitTypes.Length && !cardSuitTypes.All(t => configuration.CardSuits.Contains(t)))
            {
                string errorMessage = "Expected card suit types could not ne acquired from the configuration file!";
                Assert.Fail(errorMessage);
            }
        }
コード例 #7
0
ファイル: AceCard.cs プロジェクト: dzhahm/BlackjackGame
        public AceCard(ECardSuitTypes cardSuitType) : base(11, cardSuitType, ECardType.Ace)
        {
            CardDeckConfiguration config = new CardDeckConfigurationProvider().GetRules();

            _value = config.DefaultAceValue;
        }