Exemple #1
0
        public void OptimalSort()
        {
            List <IAnimal> animals = new List <IAnimal>();

            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Large));
            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Small));
            animals.Add(AnimalCreator.CreateCarnivore(Sizes.Small));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Large));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));
            animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle));

            sorter = new Sorter(animals);
            List <Wagon> wagons = sorter.Sort();

            //Wagon 1
            Assert.IsTrue(wagons[0].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[0].Animals[0].Size, Sizes.Large);

            //Wagon 2
            Assert.IsTrue(wagons[1].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[1].Animals[0].Size, Sizes.Small);
            Assert.IsTrue(wagons[1].Animals[1] is Herbivore);
            Assert.AreEqual(wagons[1].Animals[1].Size, Sizes.Large);
            Assert.IsTrue(wagons[1].Animals[2] is Herbivore);
            Assert.AreEqual(wagons[1].Animals[2].Size, Sizes.Middle);

            //Wagon 4
            Assert.IsTrue(wagons[2].Animals[0] is Carnivore);
            Assert.AreEqual(wagons[2].Animals[0].Size, Sizes.Small);
            Assert.IsTrue(wagons[2].Animals[1] is Herbivore);
            Assert.AreEqual(wagons[2].Animals[1].Size, Sizes.Middle);
        }
Exemple #2
0
        public void CapacityLowers()
        {
            int capacity = wagon.Capacity;

            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsTrue(wagon.Capacity < capacity);
        }
Exemple #3
0
        public void CanAddAnimal()
        {
            Carnivore animal = AnimalCreator.CreateCarnivore(Sizes.Large);

            wagon.AddAnimal(animal);

            Assert.IsTrue(wagon.Animals.Contains(animal));
        }
Exemple #4
0
        public void ConctructorAddsAnimal()
        {
            Carnivore animal = AnimalCreator.CreateCarnivore(Sizes.Large);

            wagon = new Wagon(animal);

            Assert.IsTrue(wagon.Animals.Contains(animal));
        }
Exemple #5
0
        public void NoCarnivoresTogether()
        {
            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Middle)));
        }
Exemple #6
0
        public void NoSmallerHerbivoreWithCarnivore()
        {
            wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large));

            Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Middle)));
        }