public void GetRole_UserRoleNotExists_ThrowException() { var discordRole = new AppDiscordRole(); _userRoleRepoMock .Setup(x => x.GetRoleByDiscordRoleId(It.IsAny <ulong>())) .ReturnsAsync((UserRole)null !); _sut = BuildSutWithMocks(); Func <Task> act = async() => await _sut.GetRole(discordRole); act.Should() .ThrowAsync <ArgumentException>() .WithMessage("User role doesn't exist"); }
public async Task GetRole(CommandContext ctx, DiscordRole role) { var appDiscordRole = DiscordRoleMapper.Map(role); var userRole = await _userRoleService.GetRole(appDiscordRole); var sb = new StringBuilder(); var formattedAliasList = string.Join(", ", userRole.UserRoleAliases.Select(x => x.Alias)); var groupNumberString = userRole.GroupNumber.HasValue ? userRole.GroupNumber.Value.ToString() : "None"; sb.AppendLine($"**{userRole.Name}**"); sb.AppendLine($"Discord role: {role.Name} ({role.Id})"); sb.AppendLine($"Aliases: {formattedAliasList}"); sb.AppendLine($"Group number: {groupNumberString}"); var message = sb.ToString(); await ctx.RespondAsync(message); }