//Items can be removed from bag, per child only.Removing ball from the bag should not be allowed.A child's name must be specified. public void IsItemRemovedFromBag() { Bag testBag = new Bag(); testBag.AddToy("toyPlane", "Reggie"); testBag.RemoveToy("Reggie", "toyPlane"); Assert.IsFalse(testBag.Toys["Reggie"].Contains("toyPlane")); }
//Must be able to set the delivered property of a child, which defaults to false to true. public void IsChildDeliveryPropertyAccessible() { // some code to be able Bag testBag = new Bag(); testBag.AddToy("blueHat", "Arnold"); testBag.ChangeDeliveredStatus("Arnold", true); Assert.IsTrue(testBag.IsChildDelivered("Arnold")); }
//Must be able to list all toys for a given child's name. public void AreEachChildsToysListable() { // writing the test to prove that a child's toy list longer than 1 returns more than one string Bag testBag = new Bag(); testBag.AddToy("toyPlane", "Reggie"); testBag.AddToy("DinosaursLegoSet", "Reggie"); Assert.IsTrue(testBag.Toys["Reggie"].Count == 2); }
//Must be able to list all children who are getting a toy. public void AreChildrenListable() { // some code to be able Bag testBag = new Bag(); testBag.AddToy("DinosaursLegoSet", "Harold"); // actually tests amount of children, contrary to appearance of Toys.Count (keys are child names) Assert.IsTrue(testBag.Toys.Count > 0); }
//Items can be added to bag. public void IsItemAddedToBag() { Bag testBag = new Bag(); testBag.AddToy("toyFrog", "Jeffy"); Assert.AreEqual(testBag.Toys["Jeffy"].First(), "toyFrog"); }
static void Main(string[] args) { // initialize a bag Bag bagOLoot = new Bag(); // arguments switch statement // variable to determine end of loop bool runningMan = false; // renewing prompt for interacting with bag of loot while (runningMan) { Console.Write("Enter command: "); // attempt try/catch configured setter for basic validation try { bagOLoot.userInput = Convert.ToString(Console.Read()); } // exception handling catch (ArgumentException exception) { // sets error message instead of directly writing to console // once there are exceptions in the userInput, move false validState there bagOLoot.validState = false; bagOLoot.errorText = exception.Message; } } // test Console.WriteLine("user input argument: {0}", args[0]); //bagOLoot.AddToy("lego", "jeff"); switch (args[0]) { case "add": Console.WriteLine("bruh"); bagOLoot.AddToy(args[1], args[2]); break; case "remove": bagOLoot.RemoveToy(args[1], args[2]); break; case "ls": if (args.Length <= 1) { bagOLoot.ListAllChildrenWithToys(); } else { bagOLoot.ListAllToys(args[1]); } break; case "delivered": bagOLoot.ChangeDeliveredStatus(args[1], true); break; default: Console.WriteLine("You didn't write anything, try again"); break; } // end program key Console.ReadKey(); }