public void FindAllStories() { // Arrange var storyRepository = Mock.Create <IStoryRepository>(); Mock.Arrange(() => storyRepository.Get(_searchString, _currentFilter, _sortOrder, _page)) .Returns(new List <Story>(StoriesTest.Get())); // Act HomeController controller = new HomeController(storyRepository); ViewResult actionResult = (ViewResult)controller.Index(_searchString, _currentFilter, _sortOrder, _page); var model = actionResult.Model as IEnumerable <Story>; // Assert Assert.AreEqual(10, model.Count()); Assert.AreEqual("_teacher", model.ToList()[0].Author); Assert.AreEqual("News item 9", model.ToList()[3].Title); }
public void SortOrderByTitleDescending() { this._sortOrder = "Title_desc"; // Arrange var storyRepository = Mock.Create <IStoryRepository>(); Mock.Arrange(() => storyRepository.Get(_searchString, _currentFilter, _sortOrder, _page)) .Returns(StoriesTest.Get()); // Act HomeController controller = new HomeController(storyRepository); ViewResult actionResult = (ViewResult)controller.Index(_searchString, _currentFilter, _sortOrder, _page); var model = actionResult.Model as IEnumerable <Story>; // Assert Assert.AreEqual(10, model.Count()); Assert.AreEqual("News item 9", model.ToList()[0].Title); }