public async Task ThenTheInvitationIsAccepted() { //Arrange _owinWrapper.Setup(x => x.GetClaimValue("sub")).Returns("TEST"); var invitationId = 12345L; var invitation = new UserInvitationsViewModel { Invitations = new List <InvitationView> { new InvitationView { Id = invitationId, AccountName = "Test Account" } } }; _invitationOrchestrator.Setup(x => x.AcceptInvitation(It.IsAny <long>(), It.IsAny <string>())) .Returns(Task.FromResult <object>(null)); _controller = new InvitationController(_invitationOrchestrator.Object, _owinWrapper.Object, _featureToggle.Object, _userViewTestingService.Object, _configuration, _flashMessage.Object); //Act await _controller.Accept(invitationId, invitation); //Assert _invitationOrchestrator.Verify(x => x.AcceptInvitation(It.Is <long>(l => l == 12345L), It.IsAny <string>()), Times.Once); }
public async Task <ActionResult> Accept(long invitation, UserInvitationsViewModel model) { if (string.IsNullOrEmpty(OwinWrapper.GetClaimValue("sub"))) { return(RedirectToAction("Index", "Home")); } var invitationItem = model.Invitations.SingleOrDefault(c => c.Id == invitation); if (invitationItem == null) { return(RedirectToAction("Index", "Home")); } await _invitationOrchestrator.AcceptInvitation(invitationItem.Id, OwinWrapper.GetClaimValue("sub")); var flashMessage = new FlashMessageViewModel { Headline = "Invitation accepted", Message = $"You can now access the {invitationItem.AccountName} account", Severity = FlashMessageSeverityLevel.Success }; AddFlashMessageToCookie(flashMessage); return(RedirectToAction("Index", "Home")); }