public void InsertHandTest() { //Arrange cgUserDB = new CGUserDB(); CardDB cardDB = new CardDB(); //Act var userModel = cgUserDB.GetById("Test"); List <CardModel> cardsOnHand = cardDB.GetCardsByDeckId(2); List <CardModel> filteredCardsOnHand = new List <CardModel>(); for (int i = 0; i < 5; i++) { CardModel card = cardsOnHand[i]; filteredCardsOnHand.Add(card); } cgUserDB.InsertHand(filteredCardsOnHand, userModel); CGUser user = CGUserConverter.convertFromCGUserModelToCGUser(cgUserDB.GetById("Test")); //Assert Assert.IsTrue(user.cards.Count > 0); //CleanUp CGUserModel revertedUser = CGUserConverter.ConvertFromCGUserToCGUserModel(user); cgUserDB.DeleteHand(revertedUser); }
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); }
public void GetByIdTest() { cgUserDB = new CGUserDB(); CGUserModel test = cgUserDB.GetById("Test"); Assert.AreEqual("Test", test.Id); }
public void UpdateTest() { //Arrange cgUserDB = new CGUserDB(); var test = cgUserDB.GetById("Test"); var name = test.UserName; test.UserName = "******"; //Act cgUserDB.Update(test); var test2 = cgUserDB.GetById("Test"); Assert.AreNotEqual(name, test2.UserName); //Cleanup test.UserName = "******"; cgUserDB.Update(test); }
public void UpdateUserTableIdTest() { ICGUserDBIF cgUserDB = new CGUserDB(); CGUserModel user = cgUserDB.GetById("Test"); if (user.TableID == 999) { cgUserDB.UpdateUserTableId(user, 998); } else { cgUserDB.UpdateUserTableId(user, 999); } CGUserModel user2 = cgUserDB.GetById("Test"); Assert.AreNotEqual(user.TableID, user2.TableID); }
public void GetUserTableIdTest() { cgUserDB = new CGUserDB(); CGUserModel testUser = cgUserDB.GetById("Test"); var attempt = cgUserDB.GetUserTableId("Test"); Assert.AreEqual(attempt, testUser.TableID); }
public void DeleteTest() { cgUserDB = new CGUserDB(); var bob = new CGUserModel("bob", "*****@*****.**", CGUserModel.UserType.PLAYER, CGUserModel.UserStatus.INGAME); bob.Id = "asdfg09876"; cgUserDB.Insert(bob); cgUserDB.Delete(bob); bob = cgUserDB.GetById("asdfg09876"); Assert.IsNull(bob); }
public void InsertTest() { cgUserDB = new CGUserDB(); var bob = new CGUserModel("bob", "*****@*****.**", CGUserModel.UserType.PLAYER, CGUserModel.UserStatus.STUNNED); bob.Id = "qwerty12345678"; cgUserDB.Insert(bob); var anders2 = cgUserDB.GetById("qwerty12345678"); Assert.AreEqual(bob.UserName, anders2.UserName); cgUserDB.Delete(bob); }
public void GetUserByTableIdTest() { //Arrange cgUserDB = new CGUserDB(); GameTableDB gameTableDB = new GameTableDB(); var table = new GameTableModel("TestTable"); table.DeckId = 2; table.seats = 4; //Act gameTableDB.Insert(table); table = gameTableDB.GetGameTableByTableName("TestTable"); GameTable gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(table); gameTable.Users.Add(CGUserConverter.convertFromCGUserModelToCGUser(cgUserDB.GetById("Test"))); CGUserModel testUser = cgUserDB.GetById("Test"); cgUserDB.UpdateUserTableId(testUser, table.Id); List <CGUserModel> foundUser = cgUserDB.GetUserByTableId(table.Id); Assert.AreEqual(testUser.UserName, foundUser[0].UserName); gameTableDB.Delete(table); }
public void DeleteGameTableTest() { // arrange gameTableManagement = new GameTableManagement(); IGameTableDBIF tableDB = new GameTableDB(); ICGUserDBIF userDB = new CGUserDB(); CGUser user = CGUserConverter.convertFromCGUserModelToCGUser(userDB.GetById("Test")); gameTableManagement.CreateGameTable(user, "TestTable"); GameTable table = gameTableManagement.GetGameTableByTableName("TestTable"); //Act gameTableManagement.DeleteGameTable(table.Id); //Assert Assert.IsNull(tableDB.GetById(table.Id)); }
public void JoinGameTableTest() { //Assert gameTableManagement = new GameTableManagement(); ICGUserDBIF userDB = new CGUserDB(); List <GameTable> tables = (List <GameTable>)gameTableManagement.GetAll(); GameTable table = null; if (tables != null) { table = tables[0]; } CGUser user = CGUserConverter.convertFromCGUserModelToCGUser(userDB.GetById("Test")); //Act GameTable table2 = gameTableManagement.JoinGameTable(user, table); //Assert Assert.IsTrue(table.Users.Count < table2.Users.Count); //Cleanup gameTableManagement.UpdateGameTableSeats(table2, -1); userDB.UpdateUserTableId(CGUserConverter.ConvertFromCGUserToCGUserModel(user), 0); }
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); }