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); }
public string ExportDeck(string name, Deck current) { if (!Repo.IsLoadingComplete) { throw new InvalidOperationException(); } var deckToExport = DeckConverter.ConvertDeck(current, cardId => Repo.CardsById[cardId].Faces.Main?.Id); return(ExportDeckImplementation(name, deckToExport)); }
public void StartGameTest() { //Arrange GameController gameController = new GameController(); IGameDBIF gameDB = new GameDB(); IDeckDBIF deckDb = new DeckDB(); ICGUserDBIF userDB = new CGUserDB(); IGameTableDBIF gameTableDB = new GameTableDB(); List <GameModel> games = (List <GameModel>)gameDB.GetAll(); List <CGUser> users = CGUserConverter.ConvertFromListOfCGUserModelToListOfCGUser((List <CGUserModel>)userDB.GetAll()); GameTable gameTable = new GameTable { Deck = DeckConverter.ConvertFromDeckModelToDeck(deckDb.GetById(2)), seats = 4, TableName = "TestTable", }; if (users.Count > 4) { for (int i = 0; i < 4; i++) { gameTable.Users.Add(users[i]); } } gameTableDB.Insert(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable)); gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(gameTableDB.GetGameTableByTableName("TestTable")); //Act gameController.StartGame(gameTable); List <GameModel> games2 = (List <GameModel>)gameDB.GetAll(); //Assert Assert.AreNotEqual(games.Count, games2.Count); //Cleanup gameDB.Delete(gameDB.GetByTableId(gameTable.Id)); gameTableDB.Delete(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable)); }