private void AssertIsNotAuthorized(string azureUniqueId) { var toDelete = CreateParticipant( evaluation: _evaluation, azureUniqueId: Randomize.Integer().ToString() ); _authService.LoginUser(azureUniqueId); Assert.Throws <UnauthorizedAccessException>(() => _mutation.DeleteParticipant(toDelete.Id) ); }
/* Helper methods */ private void AssertCanDelete(Participant user) { var toDelete = CreateParticipant( evaluation: _evaluation, azureUniqueId: Randomize.Integer().ToString() ); _authService.LoginUser(user); int participants = NumberOfParticipants(_evaluation); _mutation.DeleteParticipant(toDelete.Id); Assert.True(NumberOfParticipants(_evaluation) == participants - 1); }
protected Participant CreateParticipant( Evaluation evaluation, string azureUniqueId = null, Organization?organization = null, Role?role = null) { if (azureUniqueId == null) { azureUniqueId = Randomize.Integer().ToString(); } Participant participant = _mutation.CreateParticipant( azureUniqueId: azureUniqueId, evaluationId: evaluation.Id, organization: organization.GetValueOrDefault(Randomize.Organization()), role: role.GetValueOrDefault(Randomize.Role()) ); return(participant); }
public void NonParcipantIsUnauthorized() { string AzureUniqueId = Randomize.Integer().ToString(); AssertIsNotAuthorized(AzureUniqueId); }