public void TestFetchSpell() { SpellBook myBook = new SpellBook (); Spell testSpell = new Heal ("Test spell"); myBook.AddSpell (testSpell); Assert.AreEqual (testSpell, myBook [0]); }
public void TestAddSpell() { SpellBook myBook = new SpellBook (); int count = myBook.SpellCount; Assert.AreEqual (0, count, "Spell Book should start with 0 spells"); myBook.AddSpell (new Teleport ("Sean's Teleporter")); myBook.AddSpell (new Heal ("Tom's Healer")); count = myBook.SpellCount; Assert.AreEqual (2, count, "Adding two shapes should increase the count to 2"); }
public static void Main(string[] args) { SpellBook mySpellBook = new SpellBook(); mySpellBook.AddSpell (new Teleport ("Mitch's mighty mover")); mySpellBook.AddSpell (new Heal ("Paul's potent poultice")); mySpellBook.AddSpell (new Invisibilty ("David's dashing disappearance")); mySpellBook.AddSpell (new Teleport ("Stan's stunning shifter")); mySpellBook.AddSpell (new Heal ("Lachlan's lavish longevity")); CastAll (mySpellBook); Console.WriteLine (mySpellBook [2].Name + " - " + mySpellBook [2].Cast ()); Console.ReadLine (); }
public void TestRemoveSpell() { SpellBook myBook = new SpellBook (); Spell mySpell1 = new Teleport ("Sean's Teleporter"); Spell mySpell2 = new Heal ("Tom's Healer"); Spell mySpell3 = new Invisibilty ("Ian's Invisibilty"); myBook.AddSpell (mySpell1); myBook.AddSpell (mySpell2); myBook.AddSpell (mySpell3); Assert.AreEqual (3, myBook.SpellCount); myBook.RemoveSpell (mySpell2); Assert.AreEqual (2, myBook.SpellCount); }
public static void CastAll(SpellBook mySpellBook) { for (int i = 0; i < mySpellBook.SpellCount; i++) { Console.WriteLine (mySpellBook[i].Name + " - " + mySpellBook[i].Cast()); } }