public void ShouldAddCerealBeforeFruitLoops()
        {
            CerealList testList      = Program.CreateInitialList();
            Cereal     frostedFlakes = new Cereal("Frosted Flakes");

            testList.AddBefore(frostedFlakes, "Fruit Loops");
            string[] testArr = testList.ListToArr(6);
            Assert.Equal("Frosted Flakes", testArr[1]);
            Assert.Equal("Fruit Loops", testArr[2]);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        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);
        }