Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the below code to test for pagination, and the test is failing with the following test result: Invalid setup on a non-virtual (override in VB) member: m => m.GetAllMovies()


C#
[TestMethod]

  public void CanPaginate()
  {

     // Arrange
     Mock<moviebusiness> mock = new Mock<moviebusiness>();
     mock.Setup(m => m.GetAllMovies()).Returns(new List<movieview> {
                new MovieView {MovieId = 1, Title = "M1"},
                new MovieView {MovieId = 2, Title = "M2"},
                new MovieView {MovieId = 3, Title = "M3"},
                new MovieView {MovieId = 4, Title = "M4"},
                new MovieView {MovieId = 5, Title = "M5"}
       });

      // create a controller and make the page size 3 items
      MovieController controller = new MovieController(mock.Object);
      controller.PageSize = 3;

      // Act
      MovieListViewModel result = (MovieListViewModel)controller.List(null, 2).Model;

     // Assert
     MovieView[] prodArray = result.Movies.ToArray();
     Assert.IsTrue(prodArray.Length == 2);
     Assert.AreEqual(prodArray[0].Title, "M4");
     Assert.AreEqual(prodArray[1].Title, "M5");
 }</movieview></moviebusiness></moviebusiness>
Posted
Updated 30-Jul-14 9:42am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900