public AddAatfRequestHandlerTests() { addressMapper = A.Fake <IMap <AatfAddressData, AatfAddress> >(); contactMapper = A.Fake <IMap <AatfContactData, AatfContact> >(); dataAccess = A.Fake <IGenericDataAccess>(); commonDataAccess = A.Fake <ICommonDataAccess>(); handler = new AddAatfRequestHandler(AuthorizationBuilder.CreateUserWithAllRights(), dataAccess, addressMapper, contactMapper, commonDataAccess); }
public async Task HandleAsync_WithNonInternalAccess_ThrowsSecurityException(AuthorizationBuilder.UserType userType) { var authorization = AuthorizationBuilder.CreateFromUserType(userType); var userManager = A.Fake <UserManager <ApplicationUser> >(); var handler = new AddAatfRequestHandler(authorization, dataAccess, addressMapper, contactMapper, commonDataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <AddAatf>()); 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 AddAatfRequestHandler(authorization, this.dataAccess, addressMapper, contactMapper, commonDataAccess); Func <Task> action = async() => await handler.HandleAsync(A.Dummy <AddAatf>()); await Assert.ThrowsAsync <SecurityException>(action); }