Пример #1
0
        public void TestMethodTCTDJRTHTS()
        {
            var cards = new List <Card>
            {
                new Card {
                    Suit = Suit.Club, CardNumber = CardNumber.Ten
                },                                                        // 10
                new Card {
                    Suit = Suit.Diamond, CardNumber = CardNumber.Ten
                },               // 20
                new JokerCard(), // 40
                new Card {
                    Suit = Suit.Heart, CardNumber = CardNumber.Ten
                },                                                         // 30
                new Card {
                    Suit = Suit.Spade, CardNumber = CardNumber.Ten
                }                                                         // 40
            };


            IOperateCard operateCard  = new OperateCard();
            var          actualResult = operateCard.CalculateScore(cards);

            Assert.AreEqual(200, actualResult);
        }
Пример #2
0
        public ActionResult Index(string cardList)
        {
            if (!cardList.IsNullOrWhiteSpace())
            {
                var inputCards = cardList.Trim().ToUpper().Split(',');

                var realCards = new RealCards(inputCards);

                if (realCards.CardValidation.IsSuccess)
                {
                    var cards = realCards.GetCardList();

                    IOperateCard operateCard = new OperateCard();

                    var score = operateCard.CalculateScore(cards);

                    ViewBag.Message = ResultMessage.YourScore + score;

                    View(ViewBag.Message);
                }
                else
                {
                    ViewBag.Message = realCards.CardValidation.Message;
                    View(ViewBag.Message);
                }
            }

            return(View());
        }
Пример #3
0
        public void TestMethodJR()
        {
            var cards = new List <Card>
            {
                new JokerCard()
            };

            IOperateCard operateCard  = new OperateCard();
            var          actualResult = operateCard.CalculateScore(cards);

            Assert.AreEqual(0, actualResult);
        }
Пример #4
0
        public void TestMethod2C()
        {
            var cards = new List <Card>
            {
                new Card {
                    Suit = Suit.Club, CardNumber = CardNumber.Two
                }
            };

            IOperateCard operateCard  = new OperateCard();
            var          actualResult = operateCard.CalculateScore(cards);

            Assert.AreEqual(2, actualResult);
        }
Пример #5
0
        public void TestMethodACADAHAS()
        {
            var cards = new List <Card>
            {
                new Card {
                    Suit = Suit.Club, CardNumber = CardNumber.Ace
                },                                                        // 14* 1 = 14
                new Card {
                    Suit = Suit.Diamond, CardNumber = CardNumber.Ace
                },                                                           // 14* 2 = 28
                new Card {
                    Suit = Suit.Heart, CardNumber = CardNumber.Ace
                },                                                         // 14* 3 = 42
                new Card {
                    Suit = Suit.Spade, CardNumber = CardNumber.Ace
                }                                                         // 14* 4 = 56
                // Total is 140 + Additional 400
            };

            IOperateCard operateCard  = new OperateCard();
            var          actualResult = operateCard.CalculateScore(cards);

            Assert.AreEqual(540, actualResult);
        }