public void Distribute_Test_03() { //Arrange int expectedWagonAmount = 5; List <Animal> DistributedAnimals = AnimalFactory.GenerateCarnivores(expectedWagonAmount, seed); //Act List <Wagon> actualWagonList = WagonDistributor.Distribute(DistributedAnimals); //Assert Assert.AreEqual(expectedWagonAmount, actualWagonList.Count); }
public void Distribute_Test_01() { //Arrange List <Animal> Animals1 = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Carnivore, 3, 10); //Act List <Wagon> actualWagonList = WagonDistributor.Distribute(Animals1); //Assert for (int i = 0; i < actualWagonList.Count; i++) { Assert.AreEqual(Animals1[i], actualWagonList[i].FilledAnimals[0]); } }
public void Distribute_Test_04() { //Arrange List <Animal> herb = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Herbivore, 1, 10); List <Animal> Carn = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Carnivore, 3, 5); List <Animal> merged = AnimalFactory.MergeAnimalLists(herb, Carn); //Act List <Wagon> actualWagonList = WagonDistributor.Distribute(merged); //Assert foreach (var animal in merged) { var chosen = actualWagonList.Where(x => x.FilledAnimals.Contains(animal)); Assert.IsNotNull(chosen); } }
private void DistributeButton_Click(object sender, RoutedEventArgs e) { DistributeInfo.Items.Clear(); if (!_animals.Any()) { return; } var distributor = new WagonDistributor(_animals); distributor.Distribute(); var items = View(distributor); foreach (var item in items) { DistributeInfo.Items.Add(item); } }
public void Distribute_Test_02() { //Arrange List <Animal> carnivores = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Carnivore, 1, 1); List <Animal> herbivores = AnimalFactory.GenerateSelectAnimal(FoodEnum.FoodType.Herbivore, 3, 3); List <Animal> merged = AnimalFactory.MergeAnimalLists(carnivores, herbivores); //Act List <Wagon> actual = WagonDistributor.Distribute(merged); //Assert Assert.AreEqual(1, actual.Count); Assert.AreEqual(4, actual[0].FilledAnimals); for (int i = 0; i < merged.Count; i++) { Assert.AreEqual(merged[i], actual[0].FilledAnimals[i]); } }
public void AllAnimalsAdded_Test() { //Arrange int expected = 10; List <Wagon> wagons; List <Animal> animals = AnimalFactory.GenerateRandomAnimals(10, seed); //Act wagons = WagonDistributor.Distribute(animals); int actual = 0; foreach (var wagon in wagons) { actual += wagon.FilledAnimals.Count; } //Assert Assert.AreEqual(expected, actual); }
private List <String> View(WagonDistributor distributor) { var sb = new List <String>(); sb.Add("\n--- Wagon Distribution ---\n"); sb.Add("Total Amount of wagons: " + distributor.WagonList.Count); sb.Add("----------------------------------------------------\n"); for (var i = 0; i < distributor.WagonList.Count; i++) { var wagon = distributor.WagonList[i]; var animals = wagon.Animals.ToList(); sb.Add("Wagon " + (i + 1) + ":\n\n" + animals.Count + " animals\n"); for (var j = 0; j < animals.Count; j++) { var animal = animals[j]; sb.Add("Animal " + (j + 1) + " - " + animal); } sb.Add("---------------------------------------------------- +"); sb.Add("Total points: " + wagon.Points + "\n\n"); } return(sb); }