Exemplo n.º 1
0
        public void TestRemoveCreature()
        {
            Creature        cOne           = new Creature();
            Creature        cTWo           = new Creature();
            Creature        cThree         = new Creature();
            Creature        cFour          = new Creature();
            Creature        cFive          = new Creature();
            string          NAME           = "Balzeria";
            string          CLASSIFICATION = "Republic";
            List <Creature> CREATURES      = new List <Creature>()
            {
                cOne, cTWo, cThree, cFour, cFive
            };
            Society         society       = new Society(NAME, CLASSIFICATION, CREATURES);
            List <Creature> creaturesList = new List <Creature>();

            Assert.IsTrue(society.GetCreatures(out creaturesList));
            Assert.IsTrue(society.RemoveCreature(cTWo));
            Assert.IsTrue(society.GetCreatures(out creaturesList));
            CollectionAssert.Contains(creaturesList, cOne);
            CollectionAssert.DoesNotContain(creaturesList, cTWo);
            CollectionAssert.Contains(creaturesList, cThree);
            CollectionAssert.Contains(creaturesList, cFour);
            CollectionAssert.Contains(creaturesList, cFive);
        }
Exemplo n.º 2
0
 private void removeCreatureToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (siOne > -1)
     {
         DialogResult result = MessageBox.Show("Are you sure you want to delete " + creatureList[siOne].Name + " ? ", "Creature Deletion", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             society.RemoveCreature(creatureList[siOne]);
             RefreshCreatureList();
             RefreshPopulation();
         }
     }
     else
     {
         MessageBox.Show("Please select a creature to remove", "Creature Deletion", MessageBoxButtons.OK);
     }
 }