public void GetActionTest() { var unowned = -1; var owner = 2; var group = new Group(1, 50); Property property = new Street(1, group, 60, new int[] { 2, 10, 30, 90, 160, 250 }, "Mediterranean Ave"); //Property is not owned, can be bought property.BoughtByPlayer(unowned); Assert.AreEqual(Actions.canBuy, property.GetAction()); //Property is owned, must pay rent property.BoughtByPlayer(owner); Assert.AreEqual(Actions.payRent, property.GetAction()); }
public void CannotBuildTest() { var player1 = 1; var player2 = 2; var group = new Group(3, 50); var group1 = new Group(1, 50); var street = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street1 = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street2 = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street3 = new Street(21, group1, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); //Player does not have a monopoly street.BoughtByPlayer(player1); street1.BoughtByPlayer(player1); street2.BoughtByPlayer(player2); street3.BoughtByPlayer(player1); Assert.IsFalse(street.CanPlayerBuild(player1)); Assert.IsFalse(street2.CanPlayerBuild(player2)); //Monopoly belongs to another player Assert.IsFalse(street3.CanPlayerBuild(player2)); //street3.DevelopProperty(-1); //Assert.IsFalse(street3.CanPlayerBuild(player1)); }
public void GetAmountTest() { var player = new Player(); var group = new Group(3); //test get amount player owns with none owned or created Assert.ThrowsException <NullReferenceException>(() => group.GetAmountPlayerOwns(0)); //test get amount player owns with none owned and streets created var street1 = new Street(6, group, 100, new int[] { 6, 30, 90, 270, 400, 550 }, "Oriental Ave"); var street2 = new Street(8, group, 100, new int[] { 6, 30, 90, 270, 400, 550 }, "Vermont Ave"); var street3 = new Street(9, group, 120, new int[] { 8, 40, 100, 300, 450, 600 }, "Connecticut Ave"); Assert.AreEqual(0, group.GetAmountPlayerOwns(0)); //test get amount player owns with 1 street1.BoughtByPlayer(0); Assert.AreEqual(1, group.GetAmountPlayerOwns(0)); //test get amount player owns with 2 street2.BoughtByPlayer(0); Assert.AreEqual(2, group.GetAmountPlayerOwns(0)); //test get amount with 3 street3.BoughtByPlayer(0); Assert.AreEqual(3, group.GetAmountPlayerOwns(0)); }
public void BoughtByPlayerTest() { var player = 1; var group = new Group(1, 50); Property property = new Street(1, group, 60, new int[] { 2, 10, 30, 90, 160, 250 }, "Mediterranean Ave"); Assert.AreEqual(60, property.BoughtByPlayer(player)); //player purchased property Assert.AreEqual(player, property.owner); //Player owns the property }
public void CanBeMortgagedOneStreet() { //Test one Street var player = 1; var group = new Group(1, 50); var street = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); //Player owns the street street.BoughtByPlayer(player); group.GetAmountPlayerOwns(player); Assert.IsTrue(street.CanBeMortaged()); street.DevelopProperty(-1); //Street already mortgaged Assert.IsFalse(street.CanBeMortaged()); }
public void CanBuildTest() { var player1 = 1; var player2 = 2; var group = new Group(1, 50); var group1 = new Group(3, 50); var street = new Street(21, group, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street1 = new Street(21, group1, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street2 = new Street(21, group1, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); var street3 = new Street(21, group1, 220, new int[] { 18, 90, 250, 700, 875, 1050 }, "Kentucky Ave"); //Player owns a monopoly street.BoughtByPlayer(player1); Assert.IsTrue(street.CanPlayerBuild(player1)); street1.BoughtByPlayer(player2); street2.BoughtByPlayer(player2); street3.BoughtByPlayer(player2); Assert.IsTrue(street1.CanPlayerBuild(player2)); Assert.IsTrue(street2.CanPlayerBuild(player2)); Assert.IsTrue(street3.CanPlayerBuild(player2)); }