public void CheckFarmAnimalLion()
        {
            Mock <Animal> animal = new Mock <Animal>();

            animal.Object.Name = "Leeuw";
            Mock <Animal> animal2 = new Mock <Animal>();

            animal2.Object.Category = "Boerderij";

            List <Animal> animals = new List <Animal>();

            animals.Add(animal.Object);
            animals.Add(animal2.Object);

            booking.tempAnimals = animals;

            var result = validation.CheckFarm(booking);

            Assert.IsFalse(result);
        }
Exemplo n.º 2
0
        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));
        }