public RevokePermissionFromUserAsync()
            {
                _discordGuild = MockHelper.CreateDiscordGuild(0);
                _discordUser  = MockHelper.CreateDiscordUser(0);

                _permission = new TestPermission();
            }
            public GrantPermissionToUserAsync()
            {
                _discordGuild = MockHelper.CreateDiscordGuild(0);
                _discordUser  = MockHelper.CreateDiscordUser(0);

                _permission = new TestPermission();
            }
Beispiel #3
0
            public HasPermissionAsync()
            {
                _discordGuild = MockHelper.CreateDiscordGuild(0, 1);
                _discordRole  = MockHelper.CreateDiscordRole(0);

                var mock = new Mock <IGuildUser>();

                mock.Setup(u => u.Id).Returns(0);
                mock.Setup(u => u.RoleIds).Returns(new List <ulong> {
                    _discordRole.Id
                });

                _discordUser = mock.Object;

                var ownerMock = new Mock <IGuildUser>();

                ownerMock.Setup(u => u.Id).Returns(1);
                ownerMock.Setup(u => u.RoleIds).Returns(new List <ulong> {
                    _discordRole.Id
                });

                _discordGuildOwner = ownerMock.Object;

                _permission = new TestPermission();
            }
Beispiel #4
0
            public override async Task InitializeAsync()
            {
                var guild       = MockHelper.CreateDiscordGuild(0);
                var discordRole = MockHelper.CreateDiscordRole(1, guild);

                var result = await this.Characters.CreateCharacterRoleAsync
                             (
                    discordRole,
                    RoleAccess.Open
                             );

                _role = result.Entity;
            }
            public async void GrantedLocalPermissionReturnsFalseIfServerIDsDiffer()
            {
                var anotherServer      = MockHelper.CreateDiscordGuild(2);
                var requiredPermission = (Permission.SetClass, PermissionTarget.Self);

                var grantedPermission = new LocalPermission
                {
                    Permission      = Permission.SetClass,
                    Target          = PermissionTarget.Other,
                    ServerDiscordID = (long)anotherServer.Id
                };

                await this.Database.LocalPermissions.AddAsync(grantedPermission);

                await this.Database.SaveChangesAsync();

                Assert.False(await this.Permissions.HasPermissionAsync(this.Database, this.Guild, this.User, requiredPermission));
            }
 public GetOrRegisterServerAsync()
 {
     _discordGuild = MockHelper.CreateDiscordGuild(0);
 }
Beispiel #7
0
            public override async Task InitializeAsync()
            {
                var serverMock = MockHelper.CreateDiscordGuild(0);

                _server = (await this.Servers.GetOrRegisterServerAsync(serverMock)).Entity;
            }
 public AddServerAsync()
 {
     _discordGuild = MockHelper.CreateDiscordGuild(0);
 }
Beispiel #9
0
 public GetCharacterRoleAsync()
 {
     _discordGuild            = MockHelper.CreateDiscordGuild(0);
     _discordRole             = MockHelper.CreateDiscordRole(1, _discordGuild);
     _unregisteredDiscordRole = MockHelper.CreateDiscordRole(2, _discordGuild);
 }
Beispiel #10
0
 public CreateCharacterRoleAsync()
 {
     _discordGuild = MockHelper.CreateDiscordGuild(0);
     _discordRole  = MockHelper.CreateDiscordRole(1, _discordGuild);
 }
Beispiel #11
0
            public SetCharacterRoleAccessAsync()
            {
                var guild = MockHelper.CreateDiscordGuild(0);

                _discordRole = MockHelper.CreateDiscordRole(1, guild);
            }
 public IsServerKnownAsync()
 {
     _discordGuild = MockHelper.CreateDiscordGuild(0);
 }