Fix ChannelPermissions Modify parameter to be correct default value (#1003)
* 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.
This commit is contained in:
committed by
Christopher F
parent
f9cbff5e42
commit
a06e21261c
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user