Exemple #1
0
        public async Task AddRoleAlias(CommandContext ctx, DiscordRole role, string alias)
        {
            var appDiscordRole = DiscordRoleMapper.Map(role);

            await _userRoleService.AddRoleAlias(appDiscordRole, alias);

            await ctx.RespondAsync($"Added alias {alias} for {role.Name}");
        }
Exemple #2
0
        public void AddRoleAlias_WithEmptyName_ThrowsException(string inputAlias)
        {
            var discordRole = It.IsAny <AppDiscordRole>();
            var alias       = inputAlias;

            _sut = BuildSutWithMocks();

            Func <Task> act = async() => await _sut.AddRoleAlias(discordRole, alias);

            act.Should()
            .ThrowAsync <ArgumentException>()
            .WithMessage("Alias cannot be empty");
        }
Exemple #3
0
        public void AddRoleAlias_UserRoleNotExists_ThrowException()
        {
            var discordRole = new AppDiscordRole();
            var alias       = "alias";

            _userRoleRepoMock
            .Setup(x => x.GetRoleByDiscordRoleId(It.IsAny <ulong>()))
            .ReturnsAsync((UserRole)null !);

            _sut = BuildSutWithMocks();

            Func <Task> act = async() => await _sut.AddRoleAlias(discordRole, alias);

            act.Should()
            .ThrowAsync <ArgumentException>()
            .WithMessage("User role doesn't exist");
        }
Exemple #4
0
        public void AddRoleAlias_AliasAlreadyExists_ThrowException()
        {
            var discordRole = new AppDiscordRole();
            var alias       = "alias";

            _userRoleRepoMock
            .Setup(x => x.GetRoleByDiscordRoleId(It.IsAny <ulong>()))
            .ReturnsAsync(new UserRole());

            _userRoleRepoMock
            .Setup(x => x.GetRoleAlias(It.IsAny <string>()))
            .ReturnsAsync(new UserRoleAlias());

            _sut = BuildSutWithMocks();

            Func <Task> act = async() => await _sut.AddRoleAlias(discordRole, alias);

            act.Should()
            .ThrowAsync <ArgumentException>()
            .WithMessage("Alias already exists");
        }