Ejemplo n.º 1
0
        public void CreateHappyTest()
        {
            var crossType = new CrossType()
            {
                Id = 12, Name = "Banana"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new CrossTypesController(mockRepo.Object);

            var response = controller.Create(crossType) as RedirectToRouteResult;

            Assert.IsNotNull(response);
            Assert.IsNotNull(response.RouteValues);
            Assert.AreEqual("IndexByGenus", response.RouteValues["action"]);
        }
Ejemplo n.º 2
0
        public void GETDeleteHappyTest()
        {
            var expected = new CrossType()
            {
                Id = 12, Name = "Banana"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new CrossTypesController(mockRepo.Object);

            var response1 = controller.Create(expected) as RedirectToRouteResult;

            controller.Retire(expected.Id, expected.Id);

            var response2 = controller.Details(expected.Id) as HttpNotFoundResult;

            Assert.IsNotNull(response1);
            Assert.IsNotNull(response1.RouteValues);
            Assert.AreEqual("IndexByGenus", response1.RouteValues["action"]);

            Assert.IsTrue(response2.StatusCode == 404);
        }
Ejemplo n.º 3
0
        public void CreateWithBadSessionTest()
        {
            var crossType = new CrossType()
            {
                Id = 12, Name = "Banana"
            };
            var mockRepo = new Mock <IPlantBreedingRepo>();

            var controller = new CrossTypesController(mockRepo.Object);

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

            var response = controller.Create(crossType) as ViewResult;

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

            var actual = response.Model as CrossType;

            Assert.AreEqual(crossType, actual);
        }