public void Edit_NullId_ReturnsBadRequest() { // Arrange // Act var result = _controller.Edit((int?)null) as HttpStatusCodeResult; // Assert Assert.AreEqual(result.StatusCode, HttpStatusCode.BadRequest.GetHashCode()); }
public void Movie_Edit_Success() { // Goal: Query from our own list instead of the database. var list = new List <Movie> { new Movie() { MovieId = 1, Title = "Superman 1" }, new Movie() { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); // Arrange MoviesController controller = new MoviesController(mockContext.Object); // Act ViewResult result = controller.Edit(1) as ViewResult; // Assert Assert.IsNotNull(result); }
public void EditMovie_InvalidData() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "EditMovie_InvalidData") .Options; MoviesController controller = new MoviesController(new ApplicationDbContext(options)); var tmp = new Movie { Description = "Movie Description", Genre = Genre.Action, Rating = 5.4, Title = "Movie Title", Year = 2019 }; using (var context = new ApplicationDbContext(options)) { context.Movies.Add(tmp); context.SaveChanges(); } Movie movie = null; controller.Edit(1, movie); using (var context = new ApplicationDbContext(options)) { Assert.NotEqual("New", context.Movies.FirstOrDefault().Title); } }
public void MovieStore_EditPOST_NotValid() { // Step 1 Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); // Step 2 var movie = new Movie() { MovieId = 1, Title = "Superman 1", YearRelese = 2019 }; // Step 3 mockContext.Setup(db => db.Movies).Returns(mockSet.Object); // Arrange MoviesController controller = new MoviesController(mockContext.Object); // Act controller.ModelState.AddModelError("test", "test"); ViewResult result = controller.Edit(movie) as ViewResult; // Assert Assert.IsNotNull(result); }
public void MovieStore_Edit_IdIsNull() { var list = new List <Movie> { new Movie { MovieId = 1, Title = "Superman 1" }, new Movie { MovieId = 2, Title = "Superman 2" }, }.AsQueryable(); //2 Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); //3 mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); //4 mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Arrage MoviesController controller = new MoviesController(mockContext.Object); //Act HttpStatusCodeResult result = controller.Edit(id: null) as HttpStatusCodeResult; //Assert Assert.AreEqual(HttpStatusCode.BadRequest, (HttpStatusCode)result.StatusCode); }
public void MovieStore_EditRedirect_Success() { Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); Movie movie = new Movie() { MovieId = 1, Title = "Spiderman" }; mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(movie); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Arrange MoviesController controller = new MoviesController(mockContext.Object); controller.ModelState.Clear(); //Act RedirectToRouteResult result = controller.Edit(movie) as RedirectToRouteResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void MovieStore_Edit_TestPost() { var list = new List <Movie> { new Movie { MovieId = 1, Title = "Superman 1" }, new Movie { MovieId = 2, Title = "Superman 2" }, }.AsQueryable(); //2 Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); //3 mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); //4 mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Arrage MoviesController controller = new MoviesController(mockContext.Object); //Act ViewResult result = controller.Edit(0) as ViewResult; //Assert Assert.IsNotNull(result); }
public async Task MoviesController_SuccessfullyEdited_Edit_Post() { /// Arrange var controller = new MoviesController(_db); var movie = new Movie() { ID = 1, Title = "Hello World", ReleaseDate = DateTime.Now, Genre = "PG", Price = 100.00M, Rating = "G" }; /// Act var result = await controller.Edit(1, movie); /// Assert var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsType <Movie>(viewResult.ViewData.Model); Assert.Equal("Hello World", model.Title); }
public void Movie_Edit_IdIsNull() { // Goal: Query from our own list instead of the database. var list = new List <Movie> { new Movie() { MovieId = 1, Title = "Superman 1" }, new Movie() { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); // Arrange MoviesController controller = new MoviesController(mockContext.Object); // Act Nullable <int> id = null; HttpStatusCodeResult result = controller.Edit(id) as HttpStatusCodeResult; // Assert Assert.AreEqual(HttpStatusCode.BadRequest, (HttpStatusCode)result.StatusCode); }
public void MovieStore_Edit_IntParam_Success() { //Arrange Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); var list = new List <Movie> { new Movie { MovieId = 1, Title = "Jaws" }, new Movie { MovieId = 2, Title = "Despicable Me" } }.AsQueryable(); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Expression).Returns(list.Expression); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Controller needs a mock object for Dependency Injection MoviesController controller = new MoviesController(mockContext.Object); //Act ViewResult result = controller.Edit(1) as ViewResult; //Assert Assert.IsNotNull(result); }
public void MoviesControllerEdit() { var moviesController = new MoviesController(null, null); var result = moviesController.Edit(null); Assert.IsNotNull(result); }
public void FakeMovieEdit() { _moviesController = new MoviesController(_fakeMovieRepository); var expectedType = typeof(ActionResult); var value = _moviesController.Edit(new Movie()); Assert.IsInstanceOfType(value, expectedType); }
public void MovieStore_Edit_IntParam_NoId() { MoviesController controller = new MoviesController(); //Act int?movieId = null; HttpStatusCodeResult result = controller.Edit(movieId) as HttpStatusCodeResult; //Assert Assert.AreEqual(HttpStatusCode.BadRequest, (HttpStatusCode)result.StatusCode); }
public void MockMovieEdit() { var movie = new Movie(); var service = new Mock <IMovieRepository>(); service.Setup(x => x.GetMovieById(1)).Returns(movie); _moviesController = new MoviesController(service.Object); var expected = movie; var result = _moviesController.Edit(1); var actual = ((ViewResult)result).Model as Movie; Assert.AreEqual(actual, expected); }
public void MovieStore_Edit_Get_MovieIsNull() { // Goal: Query from our own list instead of database //step 1: var list = new List <Movie> { new Movie { MovieId = 1, Title = "Animal Crossing XL" }, new Movie { MovieId = 2, Title = "Super Mario Bros" }, }.AsQueryable(); ; // step 2 Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); //step 3 mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(list.First()); //this is required for this method to function properly, will not simply take id number Movie movie = null; mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(movie); //step 4 mockContext.Setup(expression: db => db.Movies).Returns(mockSet.Object); //arrange MoviesController controller = new MoviesController(mockContext.Object); //act HttpStatusCodeResult result = controller.Edit(id: 0) as HttpStatusCodeResult; //assert Assert.IsNotNull(result); Assert.AreEqual(expected: HttpStatusCode.NotFound, actual: (HttpStatusCode)result.StatusCode); }
public void MovieStore_Edit_Get_Success() { // Goal: Query from our own list instead of database //step 1: var list = new List <Movie> { new Movie { MovieId = 1, Title = "Animal Crossing XL" }, new Movie { MovieId = 2, Title = "Super Mario Bros" }, }.AsQueryable(); ; // step 2 Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); //step 3 mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(list.First()); //this is required for this method to function properly, will not simply take id number mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(list.First()); //step 4 mockContext.Setup(expression: db => db.Movies).Returns(mockSet.Object); //arrange MoviesController controller = new MoviesController(mockContext.Object); //act ViewResult result = controller.Edit(id: 1) as ViewResult; //assert Assert.IsNotNull(result); //test that it is recieving correct value? }
public void UpdatingMovie_ValidMovie_ShouldUpdateMovieInDb() { // Arrange _context.Movies.Add(_movieToCreate); _context.SaveChanges(); var updatedTitle = "The Dearly Departed"; var updatedMovie = _movieToCreate; updatedMovie.Title = updatedTitle; // Act _controller.Edit(updatedMovie); // Assert var updatedMovieInDb = _context.Movies.Find(_movieToCreate.Id); Assert.AreEqual(updatedTitle, updatedMovieInDb.Title); }
public void MovieStore_Edit_ValidModel() { //Goal: Query from our own list instead of the database. ////Step 1 //var list = new List<Movie> //{ // new Movie() {MovieId = 1, Title = "Superman 1"}, // new Movie() {MovieId = 2, Title = "Superman 2"} //}.AsQueryable(); //Step 2 Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); ////Step 3 //mockSet.As<IQueryable<Movie>>().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); // //mockSet.As<IQueryable<Movie>>().Setup(m => m.Provider).Returns(list.Provider); // //mockSet.As<IQueryable<Movie>>().Setup(m => m.ElementType).Returns(list.ElementType); Movie movie = new Movie() { MovieId = 1, Title = "The Matrix" }; mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(movie); mockContext.Setup(db => db.SetModified(It.IsAny <Movie>())); //Step 4 mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Arrange MoviesController controller = new MoviesController(mockContext.Object); controller.ModelState.Clear(); //Act RedirectToRouteResult result = controller.Edit(movie) as RedirectToRouteResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void Movies_Edit_Post() { // Arrange Source source = GetTestSource(); var sources = GetTestSourceSet(); Movie movie = GetTestMovie(source); var db = new Mock <IPersonalInformationManagerContext>(); db.Setup(e => e.Sources).Returns(sources); db.Setup(e => e.SetModified(It.IsAny <Movie>())); db.Setup(e => e.SaveChanges()).Returns(1); MoviesController controller = new MoviesController(db.Object); // Act var result = (RedirectToRouteResult)controller.Edit(movie, null); // Assert Assert.AreEqual("Index", result.RouteValues["action"]); }
public void MovieStore_Edit_MovieIsNull() { // Goal: Query from our own list instead of the database. // Step 1 var list = new List <Movie> { new Movie() { MovieId = 1, Title = "Spiderman 1" }, new Movie() { MovieId = 2, Title = "Spiderman 2" }, }.AsQueryable(); // Step 2 Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); // Step 3 mockSet.As <IQueryable <Movie> >().Setup(expression: m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(expression: m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(expression: m => m.ElementType).Returns(list.ElementType); mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(list.First()); Movie movie = null; mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(movie); // Step 4 mockContext.Setup(db => db.Movies).Returns(mockSet.Object); // Arrange MoviesController controller = new MoviesController(mockContext.Object); // Act HttpStatusCodeResult result = controller.Edit(id: 0) as HttpStatusCodeResult; // Assert Assert.AreEqual(expected: HttpStatusCode.NotFound, actual: (HttpStatusCode)result.StatusCode); }
public void MovieStore_EditPost_Success() { //Goal: Query from own list instead of the db var list = new List <Movie> { new Movie() { MovieId = 1, Title = "Superman 1" }, new Movie() { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.As <IQueryable <Movie> >().Setup(m => m.Provider).Returns(list.Provider); mockSet.As <IQueryable <Movie> >().Setup(m => m.ElementType).Returns(list.ElementType); mockSet.Setup(m => m.Find(It.IsAny <Object>())).Returns(list.First()); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); Movie movie = new Movie() { MovieId = 2, Title = "G-Force", YearRelease = 2000 }; //Arrange MoviesController controller = new MoviesController(mockContext.Object); //Act RedirectToRouteResult result = controller.Edit(movie) as RedirectToRouteResult; //Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void MovieStore_EditRedirect_BadRequest() { Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); //Arrange MoviesController controller = new MoviesController(mockContext.Object); //Act Movie movie = null; controller.ModelState.AddModelError("test", "test"); ViewResult result = controller.Edit(movie) as ViewResult; //Assert Assert.IsNotNull(result); }
public void MovieStore_Edit_ModelStateIsInvalid() { #region Arrange var movies = new List <Movie>() { new Movie { MovieId = 1, Title = "Superman 1", YearRelease = 2019 }, new Movie { MovieId = 2, Title = "Superman 2", YearRelease = 2007 } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(o => o.GetEnumerator()) .Returns(movies.GetEnumerator()); mockContext.Setup(o => o.Movies) .Returns(mockSet.Object); //Mock<DbConnection> mockDbConnection = new Mock<DbConnection>(); //mockDbConnection.Setup(o => o.ConnectionString).Returns("MovieStoreDbContext"); MoviesController controller = new MoviesController(mockContext.Object); //Mock<DbEntityEntry<Movie>> mockDbEntityEntry = new Mock<DbEntityEntry<Movie>>(); // Force ModelState.IsValid to be false controller.ModelState.AddModelError("key", "errorMessage"); #endregion #region Act ViewResult result = controller.Edit(movies.First()) as ViewResult; #endregion #region Assert Assert.IsNotNull(result); #endregion }
public void Movie_Edit_ModelStateIsNotValid() { // Arrange Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); MoviesController controller = new MoviesController(mockContext.Object); controller.ModelState.AddModelError("Movie", "Movie Title is required"); Movie movie = new Movie { MovieId = -1, Title = "" }; // Act ViewResult result = controller.Edit(movie) as ViewResult; // Assert Assert.IsNotNull(result); }
public void Movies_Edit_Get() { // Arrange Source source = GetTestSource(); var sources = GetTestSourceSet(); var movies = new InMemoryDbSet <Movie> { }; var db = new Mock <IPersonalInformationManagerContext>(); db.Setup(e => e.Sources).Returns(sources); db.Setup(e => e.Movies).Returns(movies); db.Setup(e => e.Movies.Find(It.IsAny <int>())).Returns(GetTestMovie(source)); MoviesController controller = new MoviesController(db.Object); // Act ViewResult result = controller.Edit(1) as ViewResult; var model = result.Model as PersonalInformationManager.Models.Movie; // Assert Assert.IsNotNull(result); Assert.AreEqual(MOVIE_TITLE, model.Title); }
public void Movie_Edit_ModelStateIsValid() { // Arrange Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockContext.Setup(db => db.Movies).Returns(mockSet.Object); mockContext.Setup(db => db.SetModified(It.IsAny <Movie>())); MoviesController controller = new MoviesController(mockContext.Object); Movie movie = new Movie { MovieId = 1, Title = "Inception", YearRelease = 2012 }; // Act RedirectToRouteResult result = controller.Edit(movie) as RedirectToRouteResult; // Assert Assert.IsNotNull(result); Assert.AreEqual("Index", result.RouteValues["action"]); }
public void MovieStore_Edit_IdNotFound() { #region Arrange var movies = new List <Movie>() { new Movie { MovieId = 1, Title = "Superman 1" }, new Movie { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(o => o.GetEnumerator()) .Returns(movies.GetEnumerator()); Movie movie = null; mockSet.Setup(o => o.Find(It.IsAny <object>())).Returns(movie); mockContext.Setup(o => o.Movies) .Returns(mockSet.Object); #endregion #region Act MoviesController controller = new MoviesController(mockContext.Object); HttpStatusCodeResult result = controller.Edit(Int32.MaxValue) as HttpStatusCodeResult; #endregion #region Assert Assert.AreEqual(HttpStatusCode.NotFound, (HttpStatusCode)result.StatusCode); #endregion }
public void MovieStore_Edit_MovieParam_BadBind() { //Arrange MoviesController controller = new MoviesController(); controller.ModelState.AddModelError("key", "error message"); var list = new List <Movie> { new Movie { MovieId = 1, Title = "Jaws" }, new Movie { MovieId = 2, Title = "Despicable Me" } }.AsQueryable(); //Act var result = controller.Edit(list.First()) as ViewResult; //Assert Assert.IsNotNull(result); }
public void MovieStore_EditePostFail() { // Goal: Query from out own list instead of the database. // Set up own list var list = new List <Movie> { new Movie() { MovieId = 1, Title = "Superman 1" }, new Movie() { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); // Step 2 Mock <MovieStoreDBContext> mockContext = new Mock <MovieStoreDBContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); // Step 3 mockSet.As <IQueryable <Movie> >().Setup(expression: m => m.GetEnumerator()).Returns(list.GetEnumerator()); mockSet.Setup(expression: m => m.Find(It.IsAny <Object>())).Returns(list.First()); // Step 4 mockContext.Setup(expression: db => db.Movies).Returns(mockSet.Object); // Arrange MoviesController controller = new MoviesController(mockContext.Object); // Act ViewResult result = controller.Edit(id: 0) as ViewResult; // Assert Assert.IsNotNull(result); }
public void MovieStore_Edit_Success() { #region Arrange var movies = new List <Movie>() { new Movie { MovieId = 1, Title = "Superman 1" }, new Movie { MovieId = 2, Title = "Superman 2" } }.AsQueryable(); Mock <MovieStoreDbContext> mockContext = new Mock <MovieStoreDbContext>(); Mock <DbSet <Movie> > mockSet = new Mock <DbSet <Movie> >(); mockSet.As <IQueryable <Movie> >().Setup(o => o.GetEnumerator()) .Returns(movies.GetEnumerator()); mockSet.Setup(o => o.Find(It.IsAny <object>())).Returns(movies.FirstOrDefault()); mockContext.Setup(o => o.Movies) .Returns(mockSet.Object); #endregion #region Act MoviesController controller = new MoviesController(mockContext.Object); ViewResult result = controller.Edit(1) as ViewResult; #endregion #region Assert Assert.IsNotNull(result); #endregion }