Ejemplo n.º 1
0
        public void AddAnimal_CheckIfDistributionIsCorrect_True()
        {
            //Arrange
            Train  train = new Train();
            string name  = "test";

            Animal.Diets dietHerbivore = Animal.Diets.Herbivore;
            Animal.Sizes size          = Animal.Sizes.Medium;

            Animal.Diets dietCarnivore = Animal.Diets.Carnivore;

            Animal animalHerbivore = new Animal(name, dietHerbivore, size);
            Animal animalCarnivore = new Animal(name, dietCarnivore, size);


            //Act
            train.AddAnimal(name, dietHerbivore, size);
            train.AddAnimal(name, dietCarnivore, size);
            train.DistibuteAnimals();

            //Assert

            Assert.AreEqual(animalCarnivore.Diet, train.wagonListReadOnly[0].animalListReadOnly[0].Diet);
            Assert.AreEqual(animalHerbivore.Diet, train.wagonListReadOnly[1].animalListReadOnly[0].Diet);
        }
Ejemplo n.º 2
0
        public void AddAnimal_AddCorrectAnimalToWagon_True()
        {
            //Arrange
            Wagon  wagon = new Wagon();
            string name  = "test";

            Animal.Diets diet = Animal.Diets.Carnivore;
            Animal.Sizes size = Animal.Sizes.Medium;

            Animal animal = new Animal(name, diet, size);

            //Act
            wagon.AddAnimal(animal);

            //Assert
            Assert.IsTrue(wagon.animalListReadOnly[0] == animal);
        }
Ejemplo n.º 3
0
        public void AddAnimal_ExpectedAmountOfWagonsDoesNotEqualSeven_True()
        {
            // Arrange
            string name = "test";

            Animal.Diets diet         = Animal.Diets.Herbivore;
            Animal.Sizes size         = Animal.Sizes.Large;
            int          expectedSize = 7;
            Train        train        = new Train();

            // Act
            train.AddAnimal(name, diet, size);

            //Assert
            int actual = (int)train.animalListReadOnly[0].Size;

            Assert.AreNotEqual(expectedSize, actual);
        }
Ejemplo n.º 4
0
        public void DistributeAnimals_ExpectedAmountOfWagonsEqualsSixty_ExceptionThrown()
        {
            //Arrange
            Train  train = new Train();
            string name  = "test";

            Animal.Diets diet = Animal.Diets.Herbivore;
            Animal.Sizes size = Animal.Sizes.Small;
            int          expectedAmountOfWagons = 60;

            //Act
            for (int i = 0; i < 35; i++)
            {
                train.AddAnimal(name, diet, size);
            }
            train.DistibuteAnimals();

            //Assert
            int actual = train.wagonListReadOnly.Count;

            Assert.AreEqual(expectedAmountOfWagons, actual);
        }
Ejemplo n.º 5
0
        public void AddAnimal_AddTooManyAnimalsToWagon_ExceptionThrow()
        {
            //Arrange
            Wagon  wagon = new Wagon();
            string name  = "test";

            Animal.Diets diet = Animal.Diets.Carnivore;
            Animal.Sizes size = Animal.Sizes.Medium;

            Animal animal = new Animal(name, diet, size);

            int expectedAmountOfAnimalsInWagon = 25;

            //Act
            for (int i = 0; i < 25; i++)
            {
                wagon.AddAnimal(animal);
            }

            //Assert
            Assert.AreEqual(wagon.animalListReadOnly.Count, expectedAmountOfAnimalsInWagon);
        }
Ejemplo n.º 6
0
        public void AddAnimalAndDistributeAnimals_ExpectedAmountOfWagonsEqualsFive_True()
        {
            //Arrange
            Train  train = new Train();
            string name  = "test";

            Animal.Diets diet         = Animal.Diets.Herbivore;
            Animal.Sizes size1        = Animal.Sizes.Small;
            Animal.Sizes size2        = Animal.Sizes.Medium;
            Animal.Sizes size3        = Animal.Sizes.Large;
            int          expectedSize = 5;

            //Act
            train.AddAnimal(name, diet, size1);
            train.AddAnimal(name, diet, size2);
            train.AddAnimal(name, diet, size3);
            train.DistibuteAnimals();

            //Assert
            int actual = (int)train.wagonListReadOnly[0].animalListReadOnly[0].Size;

            Assert.AreEqual(expectedSize, actual);
        }
Ejemplo n.º 7
0
        public void DistributeAnimals_ExpectedAmountOfWagonsEqualsTwoBecauseOfSafety_True()
        {
            //Arrange
            Train  train = new Train();
            string name  = "test";

            Animal.Diets diet  = Animal.Diets.Herbivore;
            Animal.Diets diet2 = Animal.Diets.Carnivore;
            Animal.Sizes size1 = Animal.Sizes.Small;
            Animal.Sizes size2 = Animal.Sizes.Medium;
            Animal.Sizes size3 = Animal.Sizes.Large;
            int          expectedAmountOfWagons = 2;

            //Act
            train.AddAnimal(name, diet, size1);
            train.AddAnimal(name, diet2, size2);
            train.AddAnimal(name, diet, size3);
            train.DistibuteAnimals();

            //Assert
            int actual = train.wagonListReadOnly.Count;

            Assert.AreEqual(expectedAmountOfWagons, actual);
        }
Ejemplo n.º 8
0
 public void AddAnimal(string name, Animal.Diets diet, Animal.Sizes size)
 {
     animalList.Add(new Animal(name, diet, size));
 }