public void AddDelegate_returns_confirmation_view() { // Given var delegateUser = delegateUserCards[0]; A.CallTo(() => userService.GetDelegateUserById(delegateUser.Id)) .Returns(delegateUser); A.CallTo(() => groupsService.GetGroupName(2, 1)) .Returns("Group name"); A.CallTo( () => groupsService.AddDelegateToGroupAndEnrolOnGroupCourses( A <int> ._, delegateUser, 0 ) ).DoesNothing(); // When var result = groupDelegatesController.AddDelegate(2, 1); // Then result.Should().BeRedirectToActionResult() .WithActionName(nameof(GroupDelegatesController.ConfirmDelegateAdded)); }
AddDelegateToGroupAndEnrolOnGroupCourses_calls_AddDelegateToGroup_dataService_and_EnrolDelegateOnGroupCourses() { // Given const int groupId = 1; const int addedByAdminId = 2; var delegateUser = UserTestHelper.GetDefaultDelegateUser(); var dateTime = DateTime.UtcNow; GivenCurrentTimeIs(dateTime); A.CallTo(() => groupsDataService.GetGroupCoursesVisibleToCentre(A <int> ._)).Returns(new List <GroupCourse>()); A.CallTo(() => groupsDataService.AddDelegateToGroup(A <int> ._, A <int> ._, A <DateTime> ._, A <int> ._)) .DoesNothing(); // When groupsService.AddDelegateToGroupAndEnrolOnGroupCourses(groupId, delegateUser, addedByAdminId); // Then A.CallTo(() => groupsDataService.AddDelegateToGroup(2, 1, dateTime, 0)).MustHaveHappenedOnceExactly(); A.CallTo(() => groupsDataService.GetGroupCoursesVisibleToCentre(2)).MustHaveHappenedOnceExactly(); }