public async Task HandleAsync_WithNonInternalAccess_ThrowsSecurityException(AuthorizationBuilder.UserType userType) { var authorization = AuthorizationBuilder.CreateFromUserType(userType); var userManager = A.Fake <UserManager <ApplicationUser> >(); var handler = new DeleteAatfHandler(authorization, aatfDataAccess, organisationDataAccess, weeeContext, getAatfDeletionStatus); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <DeleteAnAatf>()); await Assert.ThrowsAsync <SecurityException>(action); }
public async Task HandleAsync_WithNonInternalAdminRole_ThrowsSecurityException() { var authorization = new AuthorizationBuilder() .AllowInternalAreaAccess() .DenyRole(Roles.InternalAdmin) .Build(); var userManager = A.Fake <UserManager <ApplicationUser> >(); var handler = new DeleteAatfHandler(authorization, aatfDataAccess, organisationDataAccess, weeeContext, getAatfDeletionStatus); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <DeleteAnAatf>()); await Assert.ThrowsAsync <SecurityException>(action); }