public void GameData_AddCards() { GameData data = new GameData(); // make 3 pot luck cards and add to game data list PotLuck potLuck1 = new PotLuck("Go To Jail", new GoToJailAction(31)); PotLuck potLuck2 = new PotLuck("Bitcoin sales, recieve £20", new ReceiveMoneyAction(20, Sender.Bank)); PotLuck potLuck3 = new PotLuck("Assessed for Repairs", new PayRepairsAction(10, 50)); List <PotLuck> potLuckPile = new List <PotLuck>() { potLuck1, potLuck2, potLuck3 }; OpportunityKnocks opKnock1 = new OpportunityKnocks("Go to Crapper street", new MoveToAction(20, true)); OpportunityKnocks opKnock2 = new OpportunityKnocks("Pay £100 fine", new PayAction(100, Recipient.FreeParking)); List <OpportunityKnocks> opKnockPile = new List <OpportunityKnocks>() { opKnock1, opKnock2 }; // adding cards to the game data for (int i = 0; i < 3; i++) { data.AddCard(potLuckPile[i]); Assert.AreEqual(i + 1, data.GetPotLuckCards().Count); // assert correct size } for (int i = 0; i < 2; i++) { data.AddCard(opKnockPile[i]); Assert.AreEqual(i + 1, data.GetOpportunityKnocksCards().Count); // assert correct size } // check all pot luck cards were added correctly for (int i = 0; i < 3; i++) { Assert.AreEqual(potLuckPile[i], data.GetPotLuckCards()[i]); } // check all opportunity knocks cards were added correctly for (int i = 0; i < 2; i++) { Assert.AreEqual(opKnockPile[i], data.GetOpportunityKnocksCards()[i]); } }
public void CreatePotLuckCard_AbstractCardType() { GoToJailAction action = new GoToJailAction(31); AbstractCard card = new PotLuck("Go To Jail!", action); // correct description var description = card.GetDescription(); Assert.AreEqual("Go To Jail!", description); // correct jail action var cardAction = card.GetAction(); Assert.AreEqual(action, cardAction); // correct card name var cardName = card.GetCardName(); Assert.AreEqual("Pot Luck", cardName); // correct string representation "Card Name: Description" var cardString = card.ToString(); Assert.AreEqual("Pot Luck: Go To Jail!", cardString); }