Exemplo n.º 1
0
        public ActionResult Create(BirdModel birdModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(birdModel));
            }

            birdRepo.AddBird(birdModel);
            return(RedirectToAction("Index"));
        }
        public void AddBirdTest()
        {
            var mockRepository = new BirdRepository();

            mockRepository.AddBird(new Bird
            {
                BirdType     = BirdType.Archie,
                Girth        = 3.21,
                Id           = 1,
                Height       = 3.3,
                Length       = 4.3,
                SpecimenName = "Archie",
                Weight       = 45.4,
                Location     = new Location {
                    Altitude = "3453", Latitude = "23423", Longitude = "12341", Name = "Cypress"
                },
                Skeleton = new Skeleton()
            });

            mockRepository.AddBird(new Bird
            {
                BirdType     = BirdType.Archie,
                Girth        = 1.21,
                Id           = 2,
                Height       = 2.3,
                Length       = 3.3,
                SpecimenName = "Archie 2",
                Weight       = 15.4,
                Location     = new Location {
                    Altitude = "3453", Latitude = "23423", Longitude = "12341", Name = "Cypress"
                },
                Skeleton = new Skeleton()
            });

            if (mockRepository.GetBirds() == null)
            {
                Assert.Fail();
            }
        }