Beispiel #1
0
        public void Can_Enqueue_An_Animal()
        {
            FifoAnimalShelter Paws = new FifoAnimalShelter();
            Cat Spaceghost         = new Cat("Spaceghost", "cat");

            Paws.Enqueue(Spaceghost);
            Animal getName = Paws.AnimalList.Peek();

            Assert.Equal("Spaceghost", getName.Name);
        }
Beispiel #2
0
        public void Cats_Only_we_Have_No_Dogs()
        {
            FifoAnimalShelter Paws = new FifoAnimalShelter();
            Cat Spaceghost         = new Cat("Spaceghost", "cat");
            Cat Harry    = new Cat("Harry", "cat");
            Cat Lucipurr = new Cat("Lucipurr", "cat");
            Cat Ethel    = new Cat("Ethel", "cat");

            Paws.Enqueue(Spaceghost);
            Paws.Enqueue(Harry);
            Paws.Enqueue(Lucipurr);
            Paws.Enqueue(Ethel);
            Assert.Throws <ArgumentOutOfRangeException>(() => Paws.Dequeue("dog"));
        }
Beispiel #3
0
        public void Can_Enqueue_Multiple_Animal_Objects()
        {
            FifoAnimalShelter Paws = new FifoAnimalShelter();
            Cat Spaceghost         = new Cat("Spaceghost", "cat");
            Cat Harry    = new Cat("Harry", "cat");
            Cat Lucipurr = new Cat("Lucipurr", "cat");
            Cat Ethel    = new Cat("Ethel", "cat");

            Paws.Enqueue(Spaceghost);
            Paws.Enqueue(Harry);
            Paws.Enqueue(Lucipurr);
            Paws.Enqueue(Ethel);
            Assert.Equal(4, Paws.AnimalList.counter);
        }
Beispiel #4
0
        public void Can_Dequeue_The_First_Dog_In_The_Line()
        {
            FifoAnimalShelter Paws = new FifoAnimalShelter();
            Dog Pickles            = new Dog("Pickles", "dog");
            Cat Lucipurr           = new Cat("Lucipurr", "cat");
            Cat Ethel = new Cat("Ethel", "cat");
            Dog Apple = new Dog("Apple", "dog");

            Paws.Enqueue(Pickles);
            Paws.Enqueue(Lucipurr);
            Paws.Enqueue(Ethel);
            Paws.Enqueue(Apple);
            Animal result = Paws.Dequeue("dog");
            string name   = result.Name;

            Assert.Equal("Pickles", name);
        }
        public void EnqueueCat()
        {
            Dog dog = new Dog();
            Cat cat = new Cat();

            FifoAnimalShelter shelter = new FifoAnimalShelter();

            shelter.ArriveAtShelter(dog);
            shelter.ArriveAtShelter(cat);

            //act: generic constraint specifies a type that matches the criteria.
            Cat result = shelter.TakeHome <Cat>();


            //Assert
            Assert.Equal(cat, result);
        }