public void CheckSnowAnimal() { Mock <Animal> animal = new Mock <Animal>(); animal.Object.Category = "Sneeuw"; List <Animal> animals = new List <Animal>(); animals.Add(animal.Object); booking.tempAnimals = animals; booking.Booking.Date = new DateTime(2020, 7, 31); var result = validation.CheckSnow(booking); Assert.IsFalse(result); }
public ActionResult AccessoiresBooking(BookingViewModel bookVM) { AnimalValidationViewModel validation = new AnimalValidationViewModel(); bookVM.Booking = dbBooking.GetBookings().Where(x => x.Id.Equals(bookVM.Booking.Id)).FirstOrDefault(); string errors = null; var selectedanimals = bookVM.Animals.Where(x => x.IsChecked == true).ToList <Animal>(); foreach (var item in selectedanimals) { bookVM.tempAnimals.Add(item); } if (validation.CheckFarm(bookVM) == false) { errors += "Je mag geen leeuw of ijsbeer boeken als je een boerderij dier hebt."; } if (validation.CheckPinguïn(bookVM) == false) { errors += "Je mag geen Pinguïn in het weekend kiezen."; } if (validation.CheckDesert(bookVM) == false) { errors += "Je mag geen beestje met het type woestijn in de maanden Oktober t/m Februari boeken."; } if (validation.CheckSnow(bookVM) == false) { errors += "Je mag geen beestje met het type sneeuw in de maanden Juni t/m Augustus boeken."; } if (errors != null) { bookVM.Animals.Clear(); getAnimals(bookVM); ViewBag.ErrorMessage = errors; return(View("AnimalsBooking", bookVM)); } foreach (var selectedanimal in selectedanimals) { dbBooking.AddAnimalsToOrder(selectedanimal.Id, bookVM.Booking.Id); var animal = dbAnimal.GetAnimals().ToList().Where(a => a.Id == selectedanimal.Id).FirstOrDefault(); bookVM.BookingAnimals.Add(animal); } foreach (var animal in dbAnimal.GetAnimals().ToList()) { foreach (Booking booking in animal.Bookings) { if (booking.Id.Equals(bookVM.Booking.Id)) { foreach (var acc in animal.Accessories) { bookVM.Accessories.Add(acc); } } } } return(View(bookVM)); }