* fix channel permissions modify parameter to use nullable boolean, correct default value * Add general tests for the ChannelPermissions.Modify method to test default values * remove unused cast in tests * add guildpermission modify no param tests * Add no-param modify tests for OverwritePermissions * fix inconsistent parameters in GuildPermissions cstr * Adjust formatting of methods and cstrs with many parameters * remove temp file that was included. no idea what that is * Fix System dependency I should really stop fixing merge conflicts in the github website.tags/2.0
| @@ -87,12 +87,27 @@ namespace Discord | |||
| /// <summary> Creates a new ChannelPermissions with the provided packed value. </summary> | |||
| public ChannelPermissions(ulong rawValue) { RawValue = rawValue; } | |||
| private ChannelPermissions(ulong initialValue, bool? createInstantInvite = null, bool? manageChannel = null, | |||
| private ChannelPermissions(ulong initialValue, | |||
| bool? createInstantInvite = null, | |||
| bool? manageChannel = null, | |||
| bool? addReactions = null, | |||
| bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null) | |||
| bool? viewChannel = null, | |||
| bool? sendMessages = null, | |||
| bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, | |||
| bool? embedLinks = null, | |||
| bool? attachFiles = null, | |||
| bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, | |||
| bool? connect = null, | |||
| bool? speak = null, | |||
| bool? muteMembers = null, | |||
| bool? deafenMembers = null, | |||
| bool? moveMembers = null, | |||
| bool? useVoiceActivation = null, | |||
| bool? manageRoles = null, | |||
| bool? manageWebhooks = null) | |||
| { | |||
| ulong value = initialValue; | |||
| @@ -121,27 +136,75 @@ namespace Discord | |||
| } | |||
| /// <summary> Creates a new ChannelPermissions with the provided permissions. </summary> | |||
| public ChannelPermissions(bool createInstantInvite = false, bool manageChannel = false, | |||
| public ChannelPermissions( | |||
| bool createInstantInvite = false, | |||
| bool manageChannel = false, | |||
| bool addReactions = false, | |||
| bool viewChannel = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false, | |||
| bool embedLinks = false, bool attachFiles = false, bool readMessageHistory = false, bool mentionEveryone = false, | |||
| bool useExternalEmojis = false, bool connect = false, bool speak = false, bool muteMembers = false, bool deafenMembers = false, | |||
| bool moveMembers = false, bool useVoiceActivation = false, bool manageRoles = false, bool manageWebhooks = false) | |||
| bool viewChannel = false, | |||
| bool sendMessages = false, | |||
| bool sendTTSMessages = false, | |||
| bool manageMessages = false, | |||
| bool embedLinks = false, | |||
| bool attachFiles = false, | |||
| bool readMessageHistory = false, | |||
| bool mentionEveryone = false, | |||
| bool useExternalEmojis = false, | |||
| bool connect = false, | |||
| bool speak = false, | |||
| bool muteMembers = false, | |||
| bool deafenMembers = false, | |||
| bool moveMembers = false, | |||
| bool useVoiceActivation = false, | |||
| bool manageRoles = false, | |||
| bool manageWebhooks = false) | |||
| : this(0, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, | |||
| embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, | |||
| speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks) | |||
| { } | |||
| /// <summary> Creates a new ChannelPermissions from this one, changing the provided non-null permissions. </summary> | |||
| public ChannelPermissions Modify(bool? createInstantInvite = null, bool? manageChannel = null, | |||
| public ChannelPermissions Modify( | |||
| bool? createInstantInvite = null, | |||
| bool? manageChannel = null, | |||
| bool? addReactions = null, | |||
| bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool useExternalEmojis = false, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null, bool? manageRoles = null, bool? manageWebhooks = null) | |||
| => new ChannelPermissions(RawValue, createInstantInvite, manageChannel, addReactions, viewChannel, sendMessages, sendTTSMessages, manageMessages, | |||
| embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, | |||
| speak, muteMembers, deafenMembers, moveMembers, useVoiceActivation, manageRoles, manageWebhooks); | |||
| bool? viewChannel = null, | |||
| bool? sendMessages = null, | |||
| bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, | |||
| bool? embedLinks = null, | |||
| bool? attachFiles = null, | |||
| bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, | |||
| bool? connect = null, | |||
| bool? speak = null, | |||
| bool? muteMembers = null, | |||
| bool? deafenMembers = null, | |||
| bool? moveMembers = null, | |||
| bool? useVoiceActivation = null, | |||
| bool? manageRoles = null, | |||
| bool? manageWebhooks = null) | |||
| => new ChannelPermissions(RawValue, | |||
| createInstantInvite, | |||
| manageChannel, | |||
| addReactions, | |||
| viewChannel, | |||
| sendMessages, | |||
| sendTTSMessages, | |||
| manageMessages, | |||
| embedLinks, | |||
| attachFiles, | |||
| readMessageHistory, | |||
| mentionEveryone, | |||
| useExternalEmojis, | |||
| connect, | |||
| speak, | |||
| muteMembers, | |||
| deafenMembers, | |||
| moveMembers, | |||
| useVoiceActivation, | |||
| manageRoles, | |||
| manageWebhooks); | |||
| public bool Has(ChannelPermission permission) => Permissions.GetValue(RawValue, permission); | |||
| @@ -84,14 +84,35 @@ namespace Discord | |||
| /// <summary> Creates a new GuildPermissions with the provided packed value. </summary> | |||
| public GuildPermissions(ulong rawValue) { RawValue = rawValue; } | |||
| private GuildPermissions(ulong initialValue, bool? createInstantInvite = null, bool? kickMembers = null, | |||
| bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null, | |||
| bool? addReactions = null, bool? viewAuditLog = null, | |||
| bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null, | |||
| bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojis = null) | |||
| private GuildPermissions(ulong initialValue, | |||
| bool? createInstantInvite = null, | |||
| bool? kickMembers = null, | |||
| bool? banMembers = null, | |||
| bool? administrator = null, | |||
| bool? manageChannels = null, | |||
| bool? manageGuild = null, | |||
| bool? addReactions = null, | |||
| bool? viewAuditLog = null, | |||
| bool? viewChannel = null, | |||
| bool? sendMessages = null, | |||
| bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, | |||
| bool? embedLinks = null, | |||
| bool? attachFiles = null, | |||
| bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, | |||
| bool? connect = null, | |||
| bool? speak = null, | |||
| bool? muteMembers = null, | |||
| bool? deafenMembers = null, | |||
| bool? moveMembers = null, | |||
| bool? useVoiceActivation = null, | |||
| bool? changeNickname = null, | |||
| bool? manageNicknames = null, | |||
| bool? manageRoles = null, | |||
| bool? manageWebhooks = null, | |||
| bool? manageEmojis = null) | |||
| { | |||
| ulong value = initialValue; | |||
| @@ -128,32 +149,96 @@ namespace Discord | |||
| } | |||
| /// <summary> Creates a new GuildPermissions with the provided permissions. </summary> | |||
| public GuildPermissions(bool createInstantInvite = false, bool kickMembers = false, | |||
| bool banMembers = false, bool administrator = false, bool manageChannels = false, bool manageGuild = false, | |||
| bool addReactions = false, bool viewAuditLog = false, | |||
| bool viewChannel = false, bool sendMessages = false, bool sendTTSMessages = false, bool manageMessages = false, | |||
| bool embedLinks = false, bool attachFiles = false, bool readMessageHistory = false, bool mentionEveryone = false, | |||
| bool useExternalEmojis = false, bool connect = false, bool speak = false, bool muteMembers = false, bool deafenMembers = false, | |||
| bool moveMembers = false, bool useVoiceActivation = false, bool? changeNickname = false, bool? manageNicknames = false, | |||
| bool manageRoles = false, bool manageWebhooks = false, bool manageEmojis = false) | |||
| : this(0, createInstantInvite: createInstantInvite, manageRoles: manageRoles, kickMembers: kickMembers, banMembers: banMembers, | |||
| administrator: administrator, manageChannels: manageChannels, manageGuild: manageGuild, addReactions: addReactions, | |||
| viewAuditLog: viewAuditLog, viewChannel: viewChannel, sendMessages: sendMessages, sendTTSMessages: sendTTSMessages, | |||
| manageMessages: manageMessages, embedLinks: embedLinks, attachFiles: attachFiles, readMessageHistory: readMessageHistory, | |||
| mentionEveryone: mentionEveryone, useExternalEmojis: useExternalEmojis, connect: connect, speak: speak, muteMembers: muteMembers, | |||
| deafenMembers: deafenMembers, moveMembers: moveMembers, useVoiceActivation: useVoiceActivation, changeNickname: changeNickname, | |||
| manageNicknames: manageNicknames, manageWebhooks: manageWebhooks, manageEmojis: manageEmojis) | |||
| public GuildPermissions( | |||
| bool createInstantInvite = false, | |||
| bool kickMembers = false, | |||
| bool banMembers = false, | |||
| bool administrator = false, | |||
| bool manageChannels = false, | |||
| bool manageGuild = false, | |||
| bool addReactions = false, | |||
| bool viewAuditLog = false, | |||
| bool viewChannel = false, | |||
| bool sendMessages = false, | |||
| bool sendTTSMessages = false, | |||
| bool manageMessages = false, | |||
| bool embedLinks = false, | |||
| bool attachFiles = false, | |||
| bool readMessageHistory = false, | |||
| bool mentionEveryone = false, | |||
| bool useExternalEmojis = false, | |||
| bool connect = false, | |||
| bool speak = false, | |||
| bool muteMembers = false, | |||
| bool deafenMembers = false, | |||
| bool moveMembers = false, | |||
| bool useVoiceActivation = false, | |||
| bool changeNickname = false, | |||
| bool manageNicknames = false, | |||
| bool manageRoles = false, | |||
| bool manageWebhooks = false, | |||
| bool manageEmojis = false) | |||
| : this(0, | |||
| createInstantInvite: createInstantInvite, | |||
| manageRoles: manageRoles, | |||
| kickMembers: kickMembers, | |||
| banMembers: banMembers, | |||
| administrator: administrator, | |||
| manageChannels: manageChannels, | |||
| manageGuild: manageGuild, | |||
| addReactions: addReactions, | |||
| viewAuditLog: viewAuditLog, | |||
| viewChannel: viewChannel, | |||
| sendMessages: sendMessages, | |||
| sendTTSMessages: sendTTSMessages, | |||
| manageMessages: manageMessages, | |||
| embedLinks: embedLinks, | |||
| attachFiles: attachFiles, | |||
| readMessageHistory: readMessageHistory, | |||
| mentionEveryone: mentionEveryone, | |||
| useExternalEmojis: useExternalEmojis, | |||
| connect: connect, | |||
| speak: speak, | |||
| muteMembers: muteMembers, | |||
| deafenMembers: deafenMembers, | |||
| moveMembers: moveMembers, | |||
| useVoiceActivation: useVoiceActivation, | |||
| changeNickname: changeNickname, | |||
| manageNicknames: manageNicknames, | |||
| manageWebhooks: manageWebhooks, | |||
| manageEmojis: manageEmojis) | |||
| { } | |||
| /// <summary> Creates a new GuildPermissions from this one, changing the provided non-null permissions. </summary> | |||
| public GuildPermissions Modify(bool? createInstantInvite = null, bool? kickMembers = null, | |||
| bool? banMembers = null, bool? administrator = null, bool? manageChannels = null, bool? manageGuild = null, | |||
| bool? addReactions = null, bool? viewAuditLog = null, | |||
| bool? viewChannel = null, bool? sendMessages = null, bool? sendTTSMessages = null, bool? manageMessages = null, | |||
| bool? embedLinks = null, bool? attachFiles = null, bool? readMessageHistory = null, bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, bool? connect = null, bool? speak = null, bool? muteMembers = null, bool? deafenMembers = null, | |||
| bool? moveMembers = null, bool? useVoiceActivation = null, bool? changeNickname = null, bool? manageNicknames = null, | |||
| bool? manageRoles = null, bool? manageWebhooks = null, bool? manageEmojis = null) | |||
| public GuildPermissions Modify( | |||
| bool? createInstantInvite = null, | |||
| bool? kickMembers = null, | |||
| bool? banMembers = null, | |||
| bool? administrator = null, | |||
| bool? manageChannels = null, | |||
| bool? manageGuild = null, | |||
| bool? addReactions = null, | |||
| bool? viewAuditLog = null, | |||
| bool? viewChannel = null, | |||
| bool? sendMessages = null, | |||
| bool? sendTTSMessages = null, | |||
| bool? manageMessages = null, | |||
| bool? embedLinks = null, | |||
| bool? attachFiles = null, | |||
| bool? readMessageHistory = null, | |||
| bool? mentionEveryone = null, | |||
| bool? useExternalEmojis = null, | |||
| bool? connect = null, | |||
| bool? speak = null, | |||
| bool? muteMembers = null, | |||
| bool? deafenMembers = null, | |||
| bool? moveMembers = null, | |||
| bool? useVoiceActivation = null, | |||
| bool? changeNickname = null, | |||
| bool? manageNicknames = null, | |||
| bool? manageRoles = null, | |||
| bool? manageWebhooks = null, | |||
| bool? manageEmojis = null) | |||
| => new GuildPermissions(RawValue, createInstantInvite, kickMembers, banMembers, administrator, manageChannels, manageGuild, addReactions, | |||
| viewAuditLog, viewChannel, sendMessages, sendTTSMessages, manageMessages, embedLinks, attachFiles, | |||
| readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, moveMembers, | |||
| @@ -1,4 +1,4 @@ | |||
| using System; | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Diagnostics; | |||
| @@ -74,12 +74,26 @@ namespace Discord | |||
| DenyValue = denyValue; | |||
| } | |||
| private OverwritePermissions(ulong allowValue, ulong denyValue, PermValue? createInstantInvite = null, PermValue? manageChannel = null, | |||
| private OverwritePermissions(ulong allowValue, ulong denyValue, | |||
| PermValue? createInstantInvite = null, | |||
| PermValue? manageChannel = null, | |||
| PermValue? addReactions = null, | |||
| PermValue? viewChannel = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, | |||
| PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, | |||
| PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, | |||
| PermValue? deafenMembers = null, PermValue? moveMembers = null, PermValue? useVoiceActivation = null, PermValue? manageRoles = null, | |||
| PermValue? viewChannel = null, | |||
| PermValue? sendMessages = null, | |||
| PermValue? sendTTSMessages = null, | |||
| PermValue? manageMessages = null, | |||
| PermValue? embedLinks = null, | |||
| PermValue? attachFiles = null, | |||
| PermValue? readMessageHistory = null, | |||
| PermValue? mentionEveryone = null, | |||
| PermValue? useExternalEmojis = null, | |||
| PermValue? connect = null, | |||
| PermValue? speak = null, | |||
| PermValue? muteMembers = null, | |||
| PermValue? deafenMembers = null, | |||
| PermValue? moveMembers = null, | |||
| PermValue? useVoiceActivation = null, | |||
| PermValue? manageRoles = null, | |||
| PermValue? manageWebhooks = null) | |||
| { | |||
| Permissions.SetValue(ref allowValue, ref denyValue, createInstantInvite, ChannelPermission.CreateInstantInvite); | |||
| @@ -108,23 +122,53 @@ namespace Discord | |||
| } | |||
| /// <summary> Creates a new ChannelPermissions with the provided permissions. </summary> | |||
| public OverwritePermissions(PermValue createInstantInvite = PermValue.Inherit, PermValue manageChannel = PermValue.Inherit, | |||
| public OverwritePermissions( | |||
| PermValue createInstantInvite = PermValue.Inherit, | |||
| PermValue manageChannel = PermValue.Inherit, | |||
| PermValue addReactions = PermValue.Inherit, | |||
| PermValue readMessages = PermValue.Inherit, PermValue sendMessages = PermValue.Inherit, PermValue sendTTSMessages = PermValue.Inherit, PermValue manageMessages = PermValue.Inherit, | |||
| PermValue embedLinks = PermValue.Inherit, PermValue attachFiles = PermValue.Inherit, PermValue readMessageHistory = PermValue.Inherit, PermValue mentionEveryone = PermValue.Inherit, | |||
| PermValue useExternalEmojis = PermValue.Inherit, PermValue connect = PermValue.Inherit, PermValue speak = PermValue.Inherit, PermValue muteMembers = PermValue.Inherit, PermValue deafenMembers = PermValue.Inherit, | |||
| PermValue moveMembers = PermValue.Inherit, PermValue useVoiceActivation = PermValue.Inherit, PermValue manageRoles = PermValue.Inherit, PermValue manageWebhooks = PermValue.Inherit) | |||
| PermValue readMessages = PermValue.Inherit, | |||
| PermValue sendMessages = PermValue.Inherit, | |||
| PermValue sendTTSMessages = PermValue.Inherit, | |||
| PermValue manageMessages = PermValue.Inherit, | |||
| PermValue embedLinks = PermValue.Inherit, | |||
| PermValue attachFiles = PermValue.Inherit, | |||
| PermValue readMessageHistory = PermValue.Inherit, | |||
| PermValue mentionEveryone = PermValue.Inherit, | |||
| PermValue useExternalEmojis = PermValue.Inherit, | |||
| PermValue connect = PermValue.Inherit, | |||
| PermValue speak = PermValue.Inherit, | |||
| PermValue muteMembers = PermValue.Inherit, | |||
| PermValue deafenMembers = PermValue.Inherit, | |||
| PermValue moveMembers = PermValue.Inherit, | |||
| PermValue useVoiceActivation = PermValue.Inherit, | |||
| PermValue manageRoles = PermValue.Inherit, | |||
| PermValue manageWebhooks = PermValue.Inherit) | |||
| : this(0, 0, createInstantInvite, manageChannel, addReactions, readMessages, sendMessages, sendTTSMessages, manageMessages, | |||
| embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, | |||
| moveMembers, useVoiceActivation, manageRoles, manageWebhooks) { } | |||
| /// <summary> Creates a new OverwritePermissions from this one, changing the provided non-null permissions. </summary> | |||
| public OverwritePermissions Modify(PermValue? createInstantInvite = null, PermValue? manageChannel = null, | |||
| public OverwritePermissions Modify( | |||
| PermValue? createInstantInvite = null, | |||
| PermValue? manageChannel = null, | |||
| PermValue? addReactions = null, | |||
| PermValue? readMessages = null, PermValue? sendMessages = null, PermValue? sendTTSMessages = null, PermValue? manageMessages = null, | |||
| PermValue? embedLinks = null, PermValue? attachFiles = null, PermValue? readMessageHistory = null, PermValue? mentionEveryone = null, | |||
| PermValue? useExternalEmojis = null, PermValue? connect = null, PermValue? speak = null, PermValue? muteMembers = null, PermValue? deafenMembers = null, | |||
| PermValue? moveMembers = null, PermValue? useVoiceActivation = null, PermValue? manageRoles = null, PermValue? manageWebhooks = null) | |||
| PermValue? readMessages = null, | |||
| PermValue? sendMessages = null, | |||
| PermValue? sendTTSMessages = null, | |||
| PermValue? manageMessages = null, | |||
| PermValue? embedLinks = null, | |||
| PermValue? attachFiles = null, | |||
| PermValue? readMessageHistory = null, | |||
| PermValue? mentionEveryone = null, | |||
| PermValue? useExternalEmojis = null, | |||
| PermValue? connect = null, | |||
| PermValue? speak = null, | |||
| PermValue? muteMembers = null, | |||
| PermValue? deafenMembers = null, | |||
| PermValue? moveMembers = null, | |||
| PermValue? useVoiceActivation = null, | |||
| PermValue? manageRoles = null, | |||
| PermValue? manageWebhooks = null) | |||
| => new OverwritePermissions(AllowValue, DenyValue, createInstantInvite, manageChannel, addReactions, readMessages, sendMessages, sendTTSMessages, manageMessages, | |||
| embedLinks, attachFiles, readMessageHistory, mentionEveryone, useExternalEmojis, connect, speak, muteMembers, deafenMembers, | |||
| moveMembers, useVoiceActivation, manageRoles, manageWebhooks); | |||
| @@ -22,6 +22,27 @@ namespace Discord | |||
| var copy = perm.Modify(); | |||
| Assert.Equal((ulong)0, copy.RawValue); | |||
| // test modify with no parameters after using all | |||
| copy = ChannelPermissions.Text; | |||
| var modified = copy.Modify(); // no params should not change the result | |||
| Assert.Equal(ChannelPermissions.Text.RawValue, modified.RawValue); | |||
| copy = ChannelPermissions.Voice; | |||
| modified = copy.Modify(); // no params should not change the result | |||
| Assert.Equal(ChannelPermissions.Voice.RawValue, modified.RawValue); | |||
| copy = ChannelPermissions.Group; | |||
| modified = copy.Modify(); // no params should not change the result | |||
| Assert.Equal(ChannelPermissions.Group.RawValue, modified.RawValue); | |||
| copy = ChannelPermissions.DM; | |||
| modified = copy.Modify(); // no params should not change the result | |||
| Assert.Equal(ChannelPermissions.DM.RawValue, modified.RawValue); | |||
| copy = new ChannelPermissions(useExternalEmojis: true); | |||
| modified = copy.Modify(); | |||
| Assert.Equal(copy.RawValue, modified.RawValue); | |||
| // test the values that are returned by ChannelPermission.All | |||
| Assert.Equal((ulong)0, ChannelPermissions.None.RawValue); | |||
| @@ -26,6 +26,18 @@ namespace Discord | |||
| // ensure that the raw values match | |||
| Assert.Equal((ulong)0, copy.RawValue); | |||
| // test modify with no parameters | |||
| copy = GuildPermissions.None.Modify(); | |||
| Assert.Equal(GuildPermissions.None.RawValue, copy.RawValue); | |||
| // test modify with no paramters on all permissions | |||
| copy = GuildPermissions.All.Modify(); | |||
| Assert.Equal(GuildPermissions.All.RawValue, copy.RawValue); | |||
| // test modify with no paramters on webhook permissions | |||
| copy = GuildPermissions.Webhook.Modify(); | |||
| Assert.Equal(GuildPermissions.Webhook.RawValue, copy.RawValue); | |||
| // test GuildPermissions.All | |||
| ulong sumOfAllGuildPermissions = 0; | |||
| foreach(var v in Enum.GetValues(typeof(GuildPermission))) | |||
| @@ -702,5 +702,71 @@ namespace Discord | |||
| return Task.CompletedTask; | |||
| } | |||
| /// <summary> | |||
| /// Tests for the <see cref="OverwritePermissions.Modify(PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?, PermValue?)"/> | |||
| /// method to ensure that the default no-param call does not modify the resulting value | |||
| /// of the OverwritePermissions. | |||
| /// </summary> | |||
| /// <returns></returns> | |||
| public Task TestOverwritePermissionModifyNoParam() | |||
| { | |||
| // test for all Text allowed, none denied | |||
| var original = new OverwritePermissions(ChannelPermissions.Text.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, text denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Text.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // category allowed, none denied | |||
| original = new OverwritePermissions(ChannelPermissions.Category.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, category denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Category.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // DM allowed, none denied | |||
| original = new OverwritePermissions(ChannelPermissions.DM.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, DM denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.DM.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // voice allowed, none denied | |||
| original = new OverwritePermissions(ChannelPermissions.Voice.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, voice denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Voice.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // group allowed, none denied | |||
| original = new OverwritePermissions(ChannelPermissions.Group.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, group denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.Group.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| // none allowed, none denied | |||
| original = new OverwritePermissions(ChannelPermissions.None.RawValue, ChannelPermissions.None.RawValue); | |||
| Assert.Equal(original.AllowValue, original.Modify().AllowValue); | |||
| Assert.Equal(original.DenyValue, original.Modify().DenyValue); | |||
| return Task.CompletedTask; | |||
| } | |||
| } | |||
| } | |||