Ejemplo n.º 1
0
        public void Wins_CurrentWinnerLowerThanBottlePrice()
        {
            var current = new Card(CardType.Blue, 12, 0);

            Assert.IsTrue(IsWinningRule.Wins(15, current, new Card(CardType.Blue, 13, 0)), "Higher card should win");
            Assert.IsFalse(IsWinningRule.Wins(15, current, new Card(CardType.Blue, 16, 0)), "Higher than bottle price should lose");
            Assert.IsFalse(IsWinningRule.Wins(15, current, new Card(CardType.Blue, 11, 0)), "Lower card should lose");
        }
Ejemplo n.º 2
0
    private static Play GetWinner(List <Play> playedCards, int bottlePrice)
    {
        Play winning = playedCards.First();

        foreach (var playedCard in playedCards.Skip(1))
        {
            if (IsWinningRule.Wins(bottlePrice, winning.Card ?? null, playedCard.Card))
            {
                winning = playedCard;
            }
        }
        return(winning);
    }
Ejemplo n.º 3
0
        public void Wins_ReturnsTrueIfCurrentWinningCardIsNotSet()
        {
            var challenger = new Card(CardType.Blue, 12, 0);

            Assert.IsTrue(IsWinningRule.Wins(1, null, challenger), "When there is no current winner, challenger wins by default");
        }