Example #1
0
        public async Task ExecuteRemoveWhenExists()
        {
            RemoveSystemRolePrivilegeCommand command;

            using (var db = _dbHelper.GetDbContext())
            {
                db.SystemRolePrivileges.RemoveRange(db.SystemRolePrivileges);
                command = new RemoveSystemRolePrivilegeCommand()
                {
                    SystemRoleId = db.SystemRoles.First().Id, PrivilegeId = db.Privileges.First().Id
                };
                db.SystemRolePrivileges.Add(new SystemRolePrivilege()
                {
                    PrivilegeId = command.PrivilegeId, SystemRoleId = command.SystemRoleId
                });
                db.SaveChanges();
            }
            using (var db = _dbHelper.GetDbContext())
            {
                db.SystemRolePrivileges.Count().ShouldEqual(1);
            }
            await _handler.ExecuteAsync(command);

            using (var db = _dbHelper.GetDbContext())
            {
                db.SystemRolePrivileges.Any().ShouldBeFalse();
            }
        }
Example #2
0
        public void Validator(Guid systemRoleId, Guid privilegeId, bool isValid)
        {
            var command = new RemoveSystemRolePrivilegeCommand()
            {
                SystemRoleId = systemRoleId, PrivilegeId = privilegeId
            };

            var result = _validator.Validate(command);

            result.IsValid.ShouldEqual(isValid);
        }
Example #3
0
        public void ValidatorValid()
        {
            RemoveSystemRolePrivilegeCommand command;

            using (var db = _dbHelper.GetDbContext())
            {
                command = new RemoveSystemRolePrivilegeCommand()
                {
                    SystemRoleId = db.SystemRoles.First().Id, PrivilegeId = db.Privileges.First().Id
                };
            }

            var result = _validator.Validate(command);

            result.IsValid.ShouldBeTrue();
        }
Example #4
0
 public async Task <IActionResult> RemovePrivilege([FromBody] RemoveSystemRolePrivilegeCommand command)
 {
     return(await _commandSender.ValidateAndSendAsync(command, ModelState));
 }