Exemple #1
0
        /// <summary>
        /// Creates a Shelter that only contains Cat nodes again for testing purposes
        /// </summary>
        /// <returns>A Shelter with three Cat nodes</returns>
        public static Shelter CatsOnly()
        {
            Cat     Rocky  = new Cat("Rocky");
            Cat     Aiesha = new Cat("Aiesha");
            Cat     Adam   = new Cat("Adam");
            Shelter result = new Shelter(Rocky);

            result.Enqueue(Aiesha);
            result.Enqueue(Adam);
            return(result);
        }
Exemple #2
0
        public void EnqueueIntoShelter()
        {
            Shelter shelter = new Shelter();
            Animal  dog     = new Animal("Dog");
            Animal  cat     = new Animal("Cat");
            Animal  turtle  = new Animal("Turtle");

            shelter.Enqueue(dog);
            shelter.Enqueue(cat);
            shelter.Enqueue(turtle);

            Assert.True(shelter.Rear.Type == "Cat");
            Assert.True(shelter.Front.Type == "Dog");
        }
Exemple #3
0
        /// <summary>
        /// Creates a shelter with five animals for the purposes of testing
        /// </summary>
        /// <returns>A shelter with five Pet nodes inside</returns>
        public static Shelter PopulateShelter()
        {
            Dog     Jason  = new Dog("Jason");
            Dog     Kim    = new Dog("Kim");
            Cat     Zach   = new Cat("Zach");
            Cat     Trini  = new Cat("Trini");
            Dog     Billy  = new Dog("Billy");
            Shelter result = new Shelter(Jason);

            result.Enqueue(Kim);
            result.Enqueue(Zach);
            result.Enqueue(Trini);
            result.Enqueue(Billy);
            return(result);
        }
Exemple #4
0
        // Ensure that the Enqueue method works on instantiated shelter
        public void ShouldEnqueueIntoShelter()
        {
            Shelter testShelter = Program.PopulateShelter();

            testShelter.Enqueue(new Dog("Tommy"));
            Assert.Equal("Tommy", testShelter.Rear.Name);
        }
Exemple #5
0
 public void Enqueue(Animal animal)
 {
     if (Shelter.Rear != null)
     {
         animal.Value += Convert.ToInt32(Shelter.Rear.Value);
     }
     Shelter.Enqueue(animal);
 }
        public static void AnimalShelter()
        {
            //enqueue, dequeueAny, dequeueDog, dequeueCat
            var shelter = new Shelter();

            shelter.Enqueue(new Animal("dog1", Species.Dog));
            shelter.Enqueue(new Animal("dog2", Species.Dog));
            shelter.Enqueue(new Animal("cat1", Species.Cat));
            shelter.Enqueue(new Animal("dog3", Species.Dog));
            shelter.Enqueue(new Animal("cat2", 0));

            Console.WriteLine(shelter.DequeueCat().ToString());
            Console.WriteLine(shelter.DequeueAny().ToString());
            Console.WriteLine(shelter.DequeueAny().ToString());
            Console.WriteLine(shelter.DequeueAny().ToString());
            Console.WriteLine(shelter.DequeueAny().ToString());
        }
        public void CanEnqueueCatToShelter()
        {
            Shelter shelter = new Shelter();
            Cat     cat     = new Cat("Moe");

            shelter.Enqueue(cat);

            Assert.Equal(cat, shelter.Animals.Peek());
        }
        public void CanEnqueueDogToShelter()
        {
            Shelter shelter = new Shelter();
            Dog     dog     = new Dog("Henry");

            shelter.Enqueue(dog);


            Assert.Equal(dog, shelter.Animals.Peek());
        }
Exemple #9
0
        public void EnqueueIntoEmptyShelter()
        {
            Shelter shelter = new Shelter();
            Animal  dog     = new Animal("Dog");

            shelter.Enqueue(dog);

            Assert.True(shelter.Rear.Type == "Dog");
            Assert.True(shelter.Front.Type == "Dog");
            Assert.True(shelter.Front.Next == null);
        }
        public void CanDequeueDogFromShelter()
        {
            Shelter shelter = new Shelter();
            Dog     dog     = new Dog("Henry");

            shelter.Enqueue(dog);

            Animal result = shelter.Dequeue("Dog");

            Assert.Equal(dog, result);
        }
        public void CanDequeueCatFromShelter()
        {
            Shelter shelter = new Shelter();
            Cat     cat     = new Cat("Moe");

            shelter.Enqueue(cat);

            Animal result = shelter.Dequeue("Cat");


            Assert.Equal(cat, result);
        }
        public void CanFindAnimalInShelter()
        {
            Shelter shelter = new Shelter();
            Cat     cat     = new Cat("Moe");
            Cat     cat2    = new Cat("Moe2");
            Cat     cat3    = new Cat("Moe3");


            Dog dog = new Dog("Henry");


            shelter.Enqueue(cat);
            shelter.Enqueue(cat2);
            shelter.Enqueue(dog);
            shelter.Enqueue(cat3);


            Animal result = shelter.Dequeue("Dog");


            Assert.Equal(dog, result);
        }
Exemple #13
0
        public void DequeueOtherAnimalOnShelter()
        {
            Shelter shelter = new Shelter();
            Animal  dog     = new Animal("Dog");
            Animal  cat     = new Animal("Cat");
            Animal  turtle  = new Animal("Turtle");

            shelter.Enqueue(dog);
            shelter.Enqueue(dog);
            shelter.Enqueue(dog);
            shelter.Enqueue(cat);
            shelter.Enqueue(cat);
            shelter.Enqueue(dog);

            Assert.True(shelter.Dequeue(turtle).Type == dog.Type);
        }
Exemple #14
0
        public void DequeueCatAnimalOnShelterMix()
        {
            Shelter shelter = new Shelter();
            Animal  dog     = new Animal("Dog");
            Animal  cat     = new Animal("Cat");

            Animal testCat = new Animal("Cat");
            Animal testDog = new Animal("Dog");

            shelter.Enqueue(dog);
            shelter.Enqueue(dog);
            shelter.Enqueue(dog);
            shelter.Enqueue(cat);
            shelter.Enqueue(dog);
            shelter.Enqueue(cat);

            Assert.True(shelter.Dequeue(cat).Type == cat.Type);
            Assert.Equal(testCat.Type, shelter.Rear.Type);
            Assert.Equal(testDog.Type, shelter.Front.Type);
        }