Пример #1
0
        public void Delete_Check_In_Use_By()
        {
            var roleRepository = Substitute.For<IRoleRepository>();
            var categoryPermissionForRoleRepository = Substitute.For<ICategoryPermissionForRoleRepository>();
            var permissionRepository = Substitute.For<IPermissionRepository>();
            var roleService = new RoleService(roleRepository, categoryPermissionForRoleRepository, permissionRepository);

            var role = new MembershipRole
            {
                Users = new List<MembershipUser>
                                           {
                                               new MembershipUser {UserName = "******"},
                                               new MembershipUser {UserName = "******"}
                                           },
                RoleName = "Role Name"
            };

            try
            {
                roleService.Delete(role);
            }
            catch (InUseUnableToDeleteException ex)
            {
                Assert.IsTrue(ex.BlockingEntities.Any());
            }
        }
Пример #2
0
        public void Delete_Exception_If_Role_Has_Multiple_Users()
        {
            var roleRepository = Substitute.For<IRoleRepository>();
            var categoryPermissionForRoleRepository = Substitute.For<ICategoryPermissionForRoleRepository>();
            var permissionRepository = Substitute.For<IPermissionRepository>();
            var roleService = new RoleService(roleRepository, categoryPermissionForRoleRepository, permissionRepository);

            var role = new MembershipRole
                           {
                               Users = new List<MembershipUser>
                                           {
                                               new MembershipUser {UserName = "******"},
                                               new MembershipUser {UserName = "******"}
                                           },
                               RoleName = "Role Name"
                           };

            roleService.Delete(role);
        }