public void GivenAContestListController_WhenIndexActionCalled_ThenCreatesAViewWithContests() { var mockContestManagementService = new Mock<IContestManagementService>(); var contestListController = new ContestListController(mockContestManagementService.Object); mockContestManagementService.Setup(cms => cms.GetAllContests()).Returns( new List<ContestViewModel> { new ContestViewModel() }); var viewModels = contestListController.Index(); var viewResult = viewModels as ViewResult; var contestViewModels = viewResult.Model as IEnumerable<ContestViewModel>; contestViewModels.Should().HaveCount(1); }
private static ContestListController GivenAContestListController(IContestManagementService mockContestManagementService) { var contestListController = new ContestListController(mockContestManagementService); return contestListController; }