/// <summary> /// A method for generating a CerealList to use for testing /// </summary> /// <returns>The Cereal list we will use to test</returns> public static CerealList generateListForTesting() { CerealList testList = new CerealList(new Cereal("Lucky Charms")); testList.AppendCereal(new Cereal("Fruit Loops")); testList.AppendCereal(new Cereal("Frosted Flakes")); testList.AppendCereal(new Cereal("Cocoa Puffs")); return(testList); }
public void ShouldAddCerealToListEnd() { CerealList testList = Program.CreateInitialList(); Cereal frostedFlakes = new Cereal("Frosted Flakes"); testList.AppendCereal(frostedFlakes); string[] testArr = testList.ListToArr(6); Assert.Equal("Frosted Flakes", testArr[5]); }
/// <summary> /// Creates a list of cereals to start the user off /// Also useful for testing /// </summary> /// <returns>A CerealList with a set of Cereal nodes already in it</returns> public static CerealList CreateInitialList() { Cereal LuckyCharms = new Cereal("Lucky Charms"); CerealList StarterList = new CerealList(LuckyCharms); Cereal AppleJacks = new Cereal("Apple Jacks"); Cereal Trix = new Cereal("Trix"); Cereal FruitLoops = new Cereal("Fruit Loops"); Cereal CocoaPebbles = new Cereal("Cocoa Pebbles"); StarterList.AddCereal(AppleJacks); StarterList.AppendCereal(Trix); StarterList.AddBefore(FruitLoops, "Lucky Charms"); StarterList.AddAfter(CocoaPebbles, "Lucky Charms"); return(StarterList); }
static void PerformAction(char pick, CerealList MyCereal) { Cereal newCer = null; string oldCer = null; Console.WriteLine("\n"); switch (pick) { case '1': newCer = new Cereal(GetNewCereal()); MyCereal.AddCereal(newCer); break; case '2': newCer = new Cereal(GetNewCereal()); MyCereal.AppendCereal(newCer); break; case '3': newCer = new Cereal(GetNewCereal()); Console.WriteLine("Which cereal should come after this new one?"); oldCer = Console.ReadLine(); MyCereal.AddBefore(newCer, oldCer); break; case '4': newCer = new Cereal(GetNewCereal()); Console.WriteLine("Which cereal should come before this new one?"); oldCer = Console.ReadLine(); MyCereal.AddAfter(newCer, oldCer); break; case '5': MyCereal.PrintList(); break; default: Console.WriteLine("Sorry, that wan't an option."); break; } UserLoop(MyCereal); }