You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

MessageHelperTests.cs 1.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Xunit;
  5. namespace Discord
  6. {
  7. /// <summary>
  8. /// Tests for <see cref="Discord.Rest.MessageHelper"/> parsing.
  9. /// </summary>
  10. public class MessageHelperTests
  11. {
  12. /// <summary>
  13. /// Tests that no tags work while they are in code blocks.
  14. /// </summary>
  15. [Theory]
  16. [InlineData("`@everyone`")]
  17. [InlineData("`<@&163184946742034432>`")]
  18. [InlineData("```@everyone```")]
  19. [InlineData("```cs \n @everyone```")]
  20. [InlineData("```cs <@&163184946742034432> ```")]
  21. [InlineData("``` test ``` ```cs <@&163184946742034432> ```")]
  22. public void NoTagsInCodeBlocks(string testData)
  23. {
  24. // don't care that I'm passing in null channels/guilds/users
  25. // as they shouldn't be required
  26. var result = Rest.MessageHelper.ParseTags(testData, null, null, null);
  27. Assert.Empty(result);
  28. }
  29. [Theory]
  30. [InlineData("`` <@&163184946742034432>")]
  31. [InlineData("``` test ``` ``` test ``` <@&163184946742034432>")]
  32. public void TagsWork(string testData) // todo better names
  33. {
  34. // don't care that I'm passing in null channels/guilds/users
  35. // as they shouldn't be required
  36. var result = Rest.MessageHelper.ParseTags(testData, null, null, null);
  37. Assert.NotEmpty(result);
  38. }
  39. }
  40. }