Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }