Exemplo n.º 1
0
        public void DetailsHappyTest()
        {
            int?id       = 12;
            var expected = new CrossType
            {
                Id   = 12,
                Name = "bananas"
            };

            var mockRepo = new Mock <IPlantBreedingRepo>();

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

            var controller = new CrossTypesController(mockRepo.Object);

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

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

            var actual = response.Model as CrossType;

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 2
0
        public void DetailsBadIdTest()
        {
            int?id = null;

            var mockRepo = new Mock <IPlantBreedingRepo>();
            //mockRepo.Setup(r => r.GetCrossType(id.Value));
            var controller = new CrossTypesController(mockRepo.Object);

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

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 400);
        }
Exemplo n.º 3
0
        public void DetailsNullTest()
        {
            int?      id       = 12;
            CrossType expected = null;

            var mockRepo = new Mock <IPlantBreedingRepo>();

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

            var controller = new CrossTypesController(mockRepo.Object);

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

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 404);
        }
Exemplo n.º 4
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);
        }