コード例 #1
0
ファイル: BirdController.cs プロジェクト: CooperZA/MIS324
        public ActionResult Create(BirdModel birdModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(birdModel));
            }

            birdRepo.AddBird(birdModel);
            return(RedirectToAction("Index"));
        }
コード例 #2
0
        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();
            }
        }