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); }
public void IsWagonListCreated() { List <IAnimal> animals = new List <IAnimal>(); animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle)); sorter = new Sorter(animals); Assert.IsNotNull(sorter.wagons); }
public void MaxCapacity() { double capacity = (double)wagon.Capacity; int amountOfAnimals = Convert.ToInt32(Math.Floor(capacity / (double)Sizes.Small)); for (int i = 0; i < amountOfAnimals; i++) { wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Small)); } Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Small))); }
public void AddsAnimalsToList() { List <IAnimal> animals = new List <IAnimal>(); animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle)); animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle)); animals.Add(AnimalCreator.CreateHerbivore(Sizes.Middle)); sorter = new Sorter(animals); foreach (IAnimal animal in animals) { Assert.IsTrue(sorter.Animals.Contains(animal)); } }
public void NoSmallerHerbivoreWithCarnivore() { wagon.AddAnimal(AnimalCreator.CreateCarnivore(Sizes.Large)); Assert.IsFalse(wagon.AddAnimal(AnimalCreator.CreateHerbivore(Sizes.Middle))); }