Example #1
0
        /// <summary>
        /// initialize players
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static Player[] initializePlayers(int n)
        {
            Player[] players = new Player[n];

            players[0] = new LuMeng(0, PlayerType.King);
            players[1] = new SunQuan(1, PlayerType.Loyal);
            players[2] = new LiuBei(2, PlayerType.Rebel);
            players[3] = new ZhangFei(3, PlayerType.Rebel);
            players[4] = new CaoCao(4, PlayerType.Spy);

            return(players);
        }
 public void CaoCaoAbtestnomockhealthless0()
 {
     {
         Attack card   = new Attack(CardSuit.Club, 1);
         IGame  game   = mocks.Stub <IGame>();
         int    health = -1;
         int    harm   = 1;
         Player p      = new CaoCao(1);
         int    old    = p.handCards.Count;
         p.health = -1;
         PhaseList ret  = p.harm(new HarmPhase(p, null, harm, card), game);
         int       newc = p.handCards.Count;
     }
 }
        public void CaoCaoAbtestnomocknull()
        {
            {
                Attack    card   = new Attack(CardSuit.Club, 1);
                IGame     game   = mocks.Stub <IGame>();
                int       health = 5;
                int       harm   = 1;
                Player    p      = new CaoCao(1);
                int       old    = p.handCards.Count;
                PhaseList ret    = p.harm(null, game);
                int       newc   = p.handCards.Count;


                Assert.IsTrue(old + 1 == newc);
            }
        }
        public void CaoCaoAbtestmock()
        {
            Player    p        = new CaoCao(1);
            Player    p2       = new ZhangFei(2);
            int       harm     = 1;
            Attack    fakeCard = mocks.DynamicMock <Attack>(CardSuit.Club, (byte)1);
            IGame     fakeGame = mocks.DynamicMock <IGame>();
            HarmPhase fakeharm = mocks.DynamicMock <HarmPhase>(p, p2, harm, fakeCard);


            int old = p.handCards.Count;

            using (mocks.Ordered())
            {
                p.handCards.Add(fakeCard);
            }
            mocks.ReplayAll();
            PhaseList ret  = p.harm(new HarmPhase(p, null, harm, fakeCard), fakeGame);
            int       newc = p.handCards.Count;

            Assert.IsTrue(old != newc);
        }