コード例 #1
0
        public void GetCardsByUserIdTest()
        {
            cardDB = new CardDB();
            var testCard1 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);
            var testCard2 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);
            var testCard3 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);
            var testCard4 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);
            var testCard5 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2);

            testCard1.Id = cardDB.InsertWithIdentity(testCard1);
            testCard2.Id = cardDB.InsertWithIdentity(testCard2);
            testCard3.Id = cardDB.InsertWithIdentity(testCard3);
            testCard4.Id = cardDB.InsertWithIdentity(testCard4);
            testCard5.Id = cardDB.InsertWithIdentity(testCard5);
            List <CardModel> cards = new List <CardModel>()
            {
                testCard1, testCard2, testCard3, testCard4, testCard5
            };
            ICGUserDBIF userDB = new CGUserDB();
            CGUserModel user   = userDB.GetById("Test");

            userDB.InsertHand(cards, user);
            List <CardModel> cardList = (List <CardModel>)cardDB.GetCardsByUserId("Test");

            Assert.IsTrue(cardList.Count > 0);
            userDB.DeleteHand(user);
            cardDB.Delete(testCard1);
            cardDB.Delete(testCard2);
            cardDB.Delete(testCard3);
            cardDB.Delete(testCard4);
            cardDB.Delete(testCard5);
        }
コード例 #2
0
        public static CGUser convertFromCGUserModelToCGUser(CGUserModel cGUserModel)
        {
            ICardDBIF        cardDB    = new CardDB();
            List <CardModel> userCards = cardDB.GetCardsByUserId(cGUserModel.Id);
            CGUser           cGUser    = new CGUser()
            {
                Id         = cGUserModel.Id,
                UserName   = cGUserModel.UserName,
                Email      = cGUserModel.Email,
                userType   = (CGUser.UserType)cGUserModel.userType,
                userStatus = (CGUser.UserStatus)cGUserModel.userStatus,
                Health     = cGUserModel.Health,
                cards      = CardConverter.ConvertFromListOfCardModelToListOfCard(userCards)
            };

            return(cGUser);
        }