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(); } }
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); }
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(); }
public async Task <IActionResult> RemovePrivilege([FromBody] RemoveSystemRolePrivilegeCommand command) { return(await _commandSender.ValidateAndSendAsync(command, ModelState)); }