public void testLandCard() { var subCard = new LandCard(3); Assert.AreEqual(subCard.amountInDeck, 3); Assert.IsInstanceOfType(subCard, typeof(LandCard)); }
public void MonopolyPlayerBuyWithChangeTest() { Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; Tuple <ReturnState, Dictionary <MoneyType, int> > actualReturn; cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 80, LandType.State); mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50); using (StringReader sr = new StringReader("0\n0\n0\n0\n0\n1\n0\n0\n0\n2")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(mediteranianCard, cell); } Assert.AreEqual(ReturnState.Success, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 320); }
public void testCard() { var testCard = new LandCard(1); testCard.build("string1", "string2", "string3"); Assert.AreEqual(testCard.cardName, "string1"); Assert.AreEqual(testCard.cost, "string2"); Assert.AreEqual(testCard.text, "string3"); }
public Tuple <ReturnState, Dictionary <MoneyType, int> > MortgageLand(LandCard card) { Tuple <ReturnState, Dictionary <MoneyType, int> > actualReturn; using (StringReader sr = new StringReader("0\n0\n0\n0\n1\n0\n0")) { Console.SetIn(sr); actualReturn = mplayer.MortgageLand(card); } return(actualReturn); }
public void shuffleCards() { int index = 0; LandCard temp = null; for (int i = 0; i < landCards.Count - 1; i++) { index = Random.Range(i, landCards.Count); temp = landCards[index]; landCards[index] = landCards[i]; landCards[i] = temp; } }
public LandCard getCard(string name) { LandCard cardFound = null; foreach (LandCard card in landCards) { if (card.isJolly() && name.Equals("Jolly")) { cardFound = card; } if (!card.isJolly() && card.getLand().Equals(name)) { cardFound = card; } } return(cardFound); }
public void MonopolyPlayerBuyLandErrorTest() { // Act BuyLand(); Tuple <ReturnState, Dictionary <MoneyType, int> > actualReturn; Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; // Buy same land again --LandAlreadyBoughtError using (StringReader sr = new StringReader("10\n2\n4\n2\n0")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(mediteranianCard, cell); } Assert.AreEqual(ReturnState.LandAlreadyBoughtError, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 300); // buy another land -- InsufficientMoney LandCell cellUS = new LandCell(5, 5, 1, 1, "US Avenue", "US Avenue", 500, LandType.State); LandCard USCard = new LandCard("US Avenue", prices, rents, 50); using (StringReader sr = new StringReader("0\n0\n0\n0\n4\n3")) { Console.SetIn(sr); actualReturn = mplayer.BuyLand(USCard, cellUS); } Assert.AreEqual(ReturnState.InsufficientMoney, actualReturn.Item1); Assert.AreEqual(mplayer.LandCards.Count, 1); Assert.AreEqual(mplayer.TotalMoney, 300); }
public void BuyLand() { Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; cell = new LandCell(2, 2, 1, 1, "Mediterranian Avenue", "Mediterranian Avenue", 100, LandType.State); mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50); using (StringReader sr = new StringReader("10\n2\n4\n2\n0")) { Console.SetIn(sr); mplayer.BuyLand(mediteranianCard, cell); } }
public void LandCardConstructorTest() { Dictionary <PropertyType, int> prices = new Dictionary <PropertyType, int>(); prices[PropertyType.House] = 100; prices[PropertyType.Hotel] = 500; Dictionary <int, int> rents = new Dictionary <int, int>(); rents[0] = 5; rents[1] = 10; rents[2] = 20; rents[3] = 30; rents[4] = 40; rents[5] = 50; LandCard mediteranianCard = new LandCard("Mediterranian Avenue", prices, rents, 50); ReturnState actualReturn; int price = mediteranianCard.RentPrice; Assert.AreEqual(5, price); // cek for buy 2 house bool validation = mediteranianCard.ValidateBuyProperty(PropertyType.House, 2); Assert.AreEqual(true, validation); // cek for buy 1 hotel validation = mediteranianCard.ValidateBuyProperty(PropertyType.Hotel, 1); Assert.AreEqual(false, validation); // add 1 hotel error actualReturn = mediteranianCard.AddProperties(PropertyType.Hotel, 1); Assert.AreEqual(ReturnState.ValidateBuyPropertyError, actualReturn); // add 2 house mediteranianCard.AddProperties(PropertyType.House, 2); // cek properties count Assert.AreEqual(2, mediteranianCard.Properties.Count); // cek rent prince Assert.AreEqual(rents[mediteranianCard.Properties.Count], mediteranianCard.RentPrice); // add 2 house mediteranianCard.AddProperties(PropertyType.House, 2); // cek properties count Assert.AreEqual(4, mediteranianCard.Properties.Count); // cek rent price Assert.AreEqual(rents[mediteranianCard.Properties.Count], mediteranianCard.RentPrice); // cek for buy 1 hotel validation = mediteranianCard.ValidateBuyProperty(PropertyType.Hotel, 1); Assert.AreEqual(true, validation); // add 1 hotel actualReturn = mediteranianCard.AddProperties(PropertyType.Hotel, 1); Assert.AreEqual(ReturnState.Success, actualReturn); // cek properties count Assert.AreEqual(5, mediteranianCard.Properties.Count); // cek rent price Assert.AreEqual(rents[mediteranianCard.Properties.Count], mediteranianCard.RentPrice); // sell 1 house // cek validation = mediteranianCard.ValidateSellProperty(PropertyType.House, 1); Assert.AreEqual(false, validation); actualReturn = mediteranianCard.RemoveProperties(PropertyType.House, 1); Assert.AreEqual(ReturnState.ValidateSellPropertyError, actualReturn); // sell 1 hotel validation = mediteranianCard.ValidateSellProperty(PropertyType.Hotel, 1); Assert.AreEqual(true, validation); actualReturn = mediteranianCard.RemoveProperties(PropertyType.Hotel, 1); Assert.AreEqual(ReturnState.Success, actualReturn); // sell 3 house validation = mediteranianCard.ValidateSellProperty(PropertyType.House, 3); Assert.AreEqual(true, validation); actualReturn = mediteranianCard.RemoveProperties(PropertyType.House, 3); Assert.AreEqual(ReturnState.Success, actualReturn); // cek properties count Assert.AreEqual(1, mediteranianCard.Properties.Count); // cek rent price Assert.AreEqual(rents[mediteranianCard.Properties.Count], mediteranianCard.RentPrice); }
public void addCard(LandCard card) { landCards.Add(card); }