public void TestDoAddMemberWithValidInput() { // Note that typically, Do is called by a PlayerDataGridAdapterCommitter, but for the sake of unit testing, we test only Do() on // one adapter. It is the responsibility of the committer class to ensure that players do not conflict. adapter.Do(); Assert.AreEqual(1, playerList.GetChildren().Count, "PlayerDataGridAdapter does not add a player properly."); List <ModelComponent> list = playerList.GetChildren(); PlayerComponent player = (PlayerComponent)list[0]; Assert.AreEqual(adapter.Player_Name, player.Name, "PlayerDataGridAdapter does not add a player properly - improper name."); Assert.AreEqual(adapter.RaceMember, player.Race, "PlayerDataGridAdapter does not add a player properly - improper race."); Assert.AreEqual(adapter.GoldMember, player.Gold, "PlayerDataGridAdapter does not add a player properly - improper gold."); Assert.AreEqual(adapter.WoodMember, player.Wood, "PlayerDataGridAdapter does not add a player properly - improper wood."); Assert.AreEqual(adapter.MetalMember, player.Metal, "PlayerDataGridAdapter does not add a player properly - improper metal."); }
public void TestDoRemovePlayerWithValidInput() { PlayerComponent playerToRemove = buildValidPlayer(); playerList.AddChild(playerToRemove); adapter = new PlayerDataGridAdapter(playerToRemove, playerList); adapter.RemovedMember = true; adapter.Do(); Assert.AreEqual(0, playerList.GetChildren().Count, "PlayerDataGridAdapter does not remove properly."); }
public void TestDoUpdatePlayerWithValidInput() { PlayerComponent playerToUpdate = buildValidPlayer(); playerList.AddChild(playerToUpdate); adapter = new PlayerDataGridAdapter(playerToUpdate, playerList); adapter.Player_Name = adapter.Player_Name + "updateAppended"; adapter.RaceMember = "Human"; // buildValidPlayer initializes as Zombie. adapter.GoldMember += 10; adapter.MetalMember += 10; adapter.WoodMember += 10; adapter.Do(); Assert.AreEqual(adapter.Player_Name, playerToUpdate.Name, "PlayerDataGridAdapter does not update name properly."); Assert.AreEqual(adapter.RaceMember, playerToUpdate.Race, "PlayerDataGridAdapter does not update race properly."); Assert.AreEqual(adapter.GoldMember, playerToUpdate.Gold, "PlayerDataGridAdapter does not update gold properly."); Assert.AreEqual(adapter.WoodMember, playerToUpdate.Wood, "PlayerDataGridAdapter does not update wood properly."); Assert.AreEqual(adapter.MetalMember, playerToUpdate.Metal, "PlayerDataGridAdapter does not update metal properly."); }