示例#1
0
        public void InsertTest()
        {
            cardDB = new CardDB();
            List <CardModel> cardList = (List <CardModel>)cardDB.GetAll();
            var testCard = new CardModel(CardModel.CardType.ATTACK, "Attack card", "It can attack", 10);

            cardDB.Insert(testCard);
            List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll();

            Assert.IsTrue(cardList.Count < updatedCardList.Count);
        }
示例#2
0
        public void DeleteTest()
        {
            cardDB = new CardDB();
            var testCard = new CardModel(CardModel.CardType.ATTACK, "Attack DeleteTest card", "It can attack", 10);

            testCard.Id = cardDB.InsertWithIdentity(testCard);
            List <CardModel> cardList = (List <CardModel>)cardDB.GetAll();

            cardDB.Delete(testCard);
            List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll();

            Assert.IsTrue(cardList.Count > updatedCardList.Count);
        }
        public void DealCardsTest()
        {
            //Arrange
            GameController   gameController = new GameController();
            ICGUserDBIF      cGUserDB       = new CGUserDB();
            IDeckDBIF        deckDB         = new DeckDB();
            ICardDBIF        cardDB         = new CardDB();
            UserManagement   userManagement = new UserManagement();
            List <CardModel> cardModels     = (List <CardModel>)cardDB.GetAll();
            List <Card>      cards          = CardConverter.ConvertFromListOfCardModelToListOfCard(cardModels);
            Deck             deck           = DeckConverter.ConvertFromDeckModelToDeck(deckDB.GetById(2));
            List <CGUser>    users          = new List <CGUser>();
            CGUser           user           = CGUserConverter.convertFromCGUserModelToCGUser(cGUserDB.GetById("Test"));

            users.Add(user);
            userManagement.DeleteHand(user);
            //Act
            gameController.DealCards(deck, users);
            List <Card> userCards = user.cards;

            //Assert
            Assert.IsTrue(userCards.Count > 0);
            //Cleanup
            userManagement.DeleteHand(user);
        }
示例#4
0
        public void GetAllTest()
        {
            cardDB = new CardDB();
            List <CardModel> cards = (List <CardModel>)cardDB.GetAll();

            Assert.IsTrue(cards.Count > 0);
        }
示例#5
0
        public void UpdateTest()
        {
            cardDB = new CardDB();
            var       testCard    = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);
            CardModel compareCard = null;

            testCard.Id   = cardDB.InsertWithIdentity(testCard);
            testCard.Name = "Hans";
            cardDB.Update(testCard);
            List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll();

            foreach (var card in updatedCardList)
            {
                if (card.Name == testCard.Name)
                {
                    compareCard = card;
                }
            }
            Assert.AreEqual(testCard.Name, compareCard.Name);
        }