public async Task SetRoleAsSafe(SetRoleCommand command, Contexts contexts) { if (!command.Safe && !command.Unsafe) { throw new NotEnoughArgumentsException(); } await this._rolesService.SetRolesAsSafe(contexts, command.Roles, setAsSafe : command.Safe); }
public void AccountSetRole_Execute_ReturnsNotFoundMessage() { var command = new SetRoleCommand(_console, LoggerMock.GetLogger <SetRoleCommand>().Object, _accountService.Object) { User = "******" }; var resultMessage = command.Execute(); Assert.Equal("User [email protected] was not found", resultMessage); }
public void AccountSetRole_Execute_ReturnsSuccessMessage() { var command = new SetRoleCommand(_console, LoggerMock.GetLogger <SetRoleCommand>().Object, _accountService.Object) { User = "******", Role = UserRole.Basic }; var resultMessage = command.Execute(); Assert.Equal("User [email protected] has been assigned to role \"Basic\"", resultMessage); }
public async Task SetRoleAsSafe(SetRoleCommand setRoleCommand, Contexts contexts) { var roles = setRoleCommand.Roles; if (roles.Count == 0 || !(setRoleCommand.Safe || setRoleCommand.Unsafe)) { throw new NotEnoughArgumentsException(); } var shouldSetToSafe = setRoleCommand.Safe; await this._rolesService.SetRolesAsSafe(contexts, roles, shouldSetToSafe); }
public Task SetRoleAsSafe(SetRoleCommand command, Contexts contexts) { if (command.Safe == command.Unsafe) { if (command.Safe) { throw new InvalidArgumentsException(); } throw new NotEnoughArgumentsException(); } if (command.Roles.Count > 5) { throw new InvalidArgumentsException(); } return(this._rolesService.SetRolesAsSafe(contexts, command.Roles, setAsSafe: command.Safe)); }