Exemplo n.º 1
0
        public void GETDeleteBadIdTest()
        {
            int?id = null;

            var mockRepo   = new Mock <IPlantBreedingRepo>();
            var controller = new CrossTypesController(mockRepo.Object);

            var response = controller.Retire(id, null) as HttpStatusCodeResult;

            //var response = new HttpStatusCodeResult(400);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 400);
        }
Exemplo n.º 2
0
        public void GETDeleteNullTest()
        {
            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.Retire(null, null) as HttpStatusCodeResult;

            Assert.IsNotNull(response);
            Assert.IsTrue(response.StatusCode == 400);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void POSTDeleteHappyCase()
        {
            int?id        = 12;
            var crossType = new CrossType
            {
                Id   = 12,
                Name = "bananas"
            };
            var genus = new List <Genus>
            {
                new Genus
                {
                    Id   = 3,
                    Name = "Rubus",
                    DefaultPlantsInRep = 3,
                    VirusLabel1        = "RBDV",
                    VirusLabel2        = "ToRSV",
                    VirusLabel3        = "SNSV",
                    Retired            = false,
                    ExternalId         = null,
                    VirusLabel4        = "BCRV"
                }
            };


            var mockRepo = new Mock <IPlantBreedingRepo>();

            mockRepo.Setup(r => r.GetCrossType(id.Value)).Returns(crossType);
            mockRepo.Setup(r => r.GetAllGenera()).Returns(genus);

            var controller = new CrossTypesController(mockRepo.Object);

            var response = controller.Retire(id, 3) as RedirectToRouteResult;

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