public void GETEditHappyTest()
        {
            int?id       = 12;
            var expected = new Origin
            {
                Id   = 12,
                Name = "bananas"
            };

            var mockRepo = new Mock <IPlantBreedingRepo>();

            mockRepo.Setup(r => r.GetOrigin(id.Value)).Returns(expected);

            var controller = new OriginsController(mockRepo.Object);

            var response = controller.Edit(id) as ViewResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Model);
            Assert.IsNotNull(response.Model as Origin);

            var actual = response.Model as Origin;

            Assert.AreEqual(expected, actual);
        }
        public void GETEditBadIdTest()
        {
            int?id = null;

            var controller = new OriginsController();

            var response = controller.Edit(id) as HttpStatusCodeResult;

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 400);
        }
        public void POSTEditHappyTest()
        {
            var origin = new Origin()
            {
                Id = 12, Name = "Banana"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new OriginsController(mockRepo.Object);

            var response = controller.Edit(origin) as RedirectToRouteResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.RouteValues);
            Assert.AreEqual("Index", response.RouteValues["action"]);
        }
        public void GETEditNullTest()
        {
            int?   id       = 12;
            Origin expected = null;

            var mockRepo = new Mock <IPlantBreedingRepo>();

            mockRepo.Setup(r => r.GetOrigin(id.Value)).Returns(expected);

            var controller = new OriginsController(mockRepo.Object);

            var response = controller.Edit(id) as HttpNotFoundResult;

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 404);
        }
        public void POSTEditWithBadSessionTest()
        {
            var origin = new Origin()
            {
                Id = 12, Name = "Banana"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new OriginsController(mockRepo.Object);

            controller.ModelState.AddModelError("test", "play them off, keyboard cat");

            var response = controller.Edit(origin) as ViewResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.Model);
            Assert.IsNotNull(response.Model as Origin);

            var actual = response.Model as Origin;

            Assert.AreEqual(origin, actual);
        }