From 0613b8d6948ef8486373806ed09ea66485599b81 Mon Sep 17 00:00:00 2001 From: Chris Johnston Date: Tue, 27 Mar 2018 00:58:32 -0700 Subject: [PATCH] Add tests --- test/Discord.Net.Tests/Tests.Channels.cs | 31 +++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/Discord.Net.Tests/Tests.Channels.cs b/test/Discord.Net.Tests/Tests.Channels.cs index b528ca5fb..6506dfd9e 100644 --- a/test/Discord.Net.Tests/Tests.Channels.cs +++ b/test/Discord.Net.Tests/Tests.Channels.cs @@ -1,4 +1,5 @@ using Discord.Rest; +using System; using System.Linq; using System.Threading.Tasks; using Xunit; @@ -140,5 +141,33 @@ namespace Discord Assert.Equal(voice3.Position, 1); Assert.Equal(voice3.UserLimit, 16); } + + [Fact] + public async Task TestChannelCategories() + { + CheckChannelCategories(_client, _guild); + } + + private async static void CheckChannelCategories(DiscordRestClient client, RestGuild guild) + { + // create some channel categories + var cat1 = await guild.CreateCategoryChannelAsync("Cat1"); + var cat2 = await guild.CreateCategoryChannelAsync("Cat2"); + + // check that both CategoryID and GetCategoryID throw NotSupportedException + // because Categories cannot be nested + Assert.Throws(() => + { + var x = cat1.CategoryId; + }); + + Assert.Throws(() => + { + var x = cat2.GetCategoryAsync(); + }); + + + // incomplete test, could use more coverage + } } -} \ No newline at end of file +}