public void CreateFilm_ReturnView()
        {
            FilmsController fContr = new FilmsController(repos.Object);

            var res = fContr.Create() as ViewResult;


            Assert.IsNotNull("Create", res.ViewName);
        }
示例#2
0
        public void CreateFilmTest()
        {
            var service    = new Mock <IFilmRepository>();
            var controller = new FilmsController(service.Object);

            var result = controller.Create();

            Assert.IsInstanceOfType(result, typeof(ViewResult));
        }
        public void CheckCreate_CreteValidModel_RedirectToIndex()
        {
            repos.Setup(m => m.addFilm(films.ElementAt(1))).Returns(true);

            FilmsController controller = new FilmsController(repos.Object);

            var res = controller.Create(films.ElementAt(1)) as RedirectToActionResult;

            Assert.AreEqual("Index", res.ActionName);
        }
示例#4
0
        public async Task CreateValidFilm()
        {
            var validFilm = new Film()
            {
                Title = "Godfather", Year = 1972, Length = 175
            };

            var service    = new Mock <IFilmRepository>();
            var controller = new FilmsController(service.Object);

            var result = await controller.Create(validFilm);

            Assert.IsInstanceOfType(result, typeof(RedirectToActionResult));
        }
        public void CheckCreate_InvalidModel_CannotAdd()
        {
            Film film = new Film()
            {
            };

            repos.Setup(m => m.addFilm(film)).Returns(false);

            FilmsController controller = new FilmsController(repos.Object);

            controller.ModelState.AddModelError("Invalid price", "error");

            controller.Create(film);

            repos.Verify(m => m.addFilm(It.IsAny <Film>()), Times.Never);
        }
示例#6
0
        public async Task CreateInvalidFilm()
        {
            string invalidTitle = "Wrong title";
            var    invalidFilm  = new Film()
            {
                Title = invalidTitle, Year = 1972, Length = 175
            };

            var service    = new Mock <IFilmRepository>();
            var controller = new FilmsController(service.Object);

            controller.ModelState.AddModelError("", "");

            var result = await controller.Create(invalidFilm);

            var model = (Film)((ViewResult)result).Model;

            Assert.AreEqual(invalidTitle, model.Title);
        }
        public void filmsCreateTest()
        {
            ViewResult result = controller.Create() as ViewResult;

            Assert.AreEqual("Create", result.ViewName);
        }
        public void TestThatAnFilmIsAddedSuccessfully()
        {
            RedirectToRouteResult result = _filmsController.Create(_film) as RedirectToRouteResult;

            Assert.AreEqual("success", result.RouteValues["Outcome"]);
        }