Beispiel #1
0
        public void ShouldNot_DeleteVenue_NotFound()
        {
            Venue testVenue = new Venue {
                Id = 10
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.Venues.GetById(10)).Returns((Venue)null);

            VenuesController controller = new VenuesController(mock.Object);
            var result = controller.DeleteVenue(10);

            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #2
0
        public void Should_DeleteVenue()
        {
            Venue testVenue = new Venue {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.Venues.GetById(1)).Returns(testVenue);
            mock.Setup(f => f.Venues.Delete(testVenue)).Returns(true);

            VenuesController controller = new VenuesController(mock.Object);
            var result = controller.DeleteVenue(1);

            Assert.IsType <OkObjectResult>(result);
        }
Beispiel #3
0
        public void ShouldNot_DeleteVenue_ModelStateError()
        {
            Venue testVenue = new Venue {
                Id = 1
            };

            Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>();

            mock.Setup(f => f.Venues.Delete(testVenue)).Returns(true);

            VenuesController controller = new VenuesController(mock.Object);

            controller.ModelState.AddModelError("TestError", "Error");
            var result = controller.DeleteVenue(1);

            Assert.IsType <BadRequestObjectResult>(result);
        }