public void DequeueOnEmptyShelter() { Shelter shelter = new Shelter(); Animal dog = new Animal("Dog"); Assert.Throws <NullReferenceException>(() => shelter.Dequeue(dog)); }
// Should Dequeue Front Pet from Shelter when no arguments are passed to Dequeue method public void ShouldDequeueAnyPet() { Shelter testShelter = Program.PopulateShelter(); Pet adopted = testShelter.Dequeue(); Assert.Equal("Kim", testShelter.Front.Name); Assert.Equal("Jason", adopted.Name); }
// Should Return the Front Pet in the case that there are no instances of the prefered Pet type in the Shelter public void ShouldReturnFirstPetIfNoPreferedExist() { Shelter catShelter = Program.CatsOnly(); Pet adopted = catShelter.Dequeue(new Dog("test")); Assert.Equal("Rocky", adopted.Name); Assert.Equal("Aiesha", catShelter.Front.Name); Assert.Equal("Adam", catShelter.Rear.Name); }
// Should Return front-most requested animal when an argument is passed into Dequeue method // Should also keep the order of the Pets unchanged otherwise public void ShouldDequeueFirstPreferredPet() { Shelter testShelter = Program.PopulateShelter(); Pet adopted = testShelter.Dequeue(new Cat("test")); Assert.Equal("Zach", adopted.Name); Assert.Equal("Jason", testShelter.Front.Name); Assert.Equal("Billy", testShelter.Rear.Name); }
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 Node <int> Dequeue(Animal pref) { Current = Shelter.Front; Oldest = Shelter.Front; if (pref is Dog) { if (Shelter.Front is Dog) { Node <Animal> result = Shelter.Dequeue(); } } if (pref is Cat) { } return(null); }
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); }
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); }
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); }