public void ReturnsNotFoundIfThereAreNotLastestStoriesWithSpecifications() { Mock <IStoryService> storyService = new Mock <IStoryService>(); storyService.Setup(s => s.GetLastestStories(It.IsAny <string>(), It.IsAny <Pagination>())).Returns <IEnumerable <Story> >(null); StoriesController storiesController = new StoriesController(storyService.Object, null); var result = storiesController.GetHome(new StoryFilterRequest() { }); Assert.IsInstanceOfType(result, typeof(NotFoundResult)); }
public void ReturnsLastestStories() { var lastestStories = new List <Story>() { new StoryBuilder().WithTitle("title 1"), new StoryBuilder().WithTitle("title 2"), }; Mock <IStoryService> storyService = new Mock <IStoryService>(); storyService.Setup(s => s.GetLastestStories(It.IsAny <string>(), It.IsAny <Pagination>())).Returns(new StaticPagedList <Story>(lastestStories)); StoriesController storiesController = new StoriesController(storyService.Object, null); var result = storiesController.GetHome(new StoryFilterRequest()) as OkNegotiatedContentResult <PagedListResponse <StoryResponse> >; Assert.IsNotNull(result); Assert.AreEqual(2, result.Content.Items.Count()); Assert.AreEqual("title 2", result.Content.Items.ToList()[1].Title); }