public void Index_returns_view_result_with_correct_group_id_for_centre() { // Given A.CallTo(() => groupsService.GetGroupName(1, 2)).Returns("Group"); A.CallTo(() => groupsService.GetGroupDelegates(1)).Returns(new List <GroupDelegate>()); // When var result = groupDelegatesController.Index(1); // Then result.Should().BeViewResult().WithDefaultViewName(); }
public IActionResult Index(int groupId, int page = 1) { var centreId = User.GetCentreId(); var groupName = groupsService.GetGroupName(groupId, centreId); var groupDelegates = groupsService.GetGroupDelegates(groupId); var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions( null, null, null, new PaginationOptions(page) ); var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate( groupDelegates, searchSortPaginationOptions ); var model = new GroupDelegatesViewModel(groupId, groupName !, result); return(View(model)); }
public IActionResult GroupDelegates(int groupId, int page = 1) { var centreId = User.GetCentreId(); var groupName = groupsService.GetGroupName(groupId, centreId); if (groupName == null) { return(NotFound()); } var groupDelegates = groupsService.GetGroupDelegates(groupId); var model = new GroupDelegatesViewModel(groupId, groupName, groupDelegates, page); return(View(model)); }
public void GetGroupName_returns_expected_group_name() { // Given const int groupId = 1; const int centreId = 1; var groupName = "Group name"; A.CallTo(() => groupsDataService.GetGroupName(groupId, centreId)).Returns(groupName); // When var result = groupsService.GetGroupName(groupId, centreId); // Then result.Should().BeEquivalentTo(groupName); }
public IActionResult ConfirmDeleteGroup(int groupId, ReturnPageQuery returnPageQuery) { var groupLabel = groupsService.GetGroupName(groupId, User.GetCentreId()) !; var delegateCount = groupsService.GetGroupDelegates(groupId).Count(); var courseCount = groupsService.GetUsableGroupCoursesForCentre(groupId, User.GetCentreId()).Count(); var model = new ConfirmDeleteGroupViewModel { GroupLabel = groupLabel, DelegateCount = delegateCount, CourseCount = courseCount, ReturnPageQuery = returnPageQuery, }; return(View(model)); }
public void GroupDelegates_returns_not_found_with_incorrect_group_id_for_centre() { // Given A.CallTo(() => groupsService.GetGroupName(1, 2)).Returns(null); // When var result = delegateGroupsController.GroupDelegates(1); // Then result.Should().BeNotFoundResult(); }