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.

Tests.cs 1.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using Discord.Net;
  3. using Discord.Rest;
  4. using Xunit;
  5. // TODO: re-enable ix testing at a later date
  6. #if IXTEST
  7. namespace Discord
  8. {
  9. public partial class TestsFixture : IDisposable
  10. {
  11. private readonly TestConfig _config;
  12. private readonly CachedRestClient _cache;
  13. internal readonly DiscordRestClient _client;
  14. internal readonly RestGuild _guild;
  15. public TestsFixture()
  16. {
  17. _cache = new CachedRestClient();
  18. _config = TestConfig.LoadFile("./config.json");
  19. var config = new DiscordRestConfig
  20. {
  21. RestClientProvider = url =>
  22. {
  23. _cache.SetUrl(url);
  24. return _cache;
  25. }
  26. };
  27. _client = new DiscordRestClient(config);
  28. _client.LoginAsync(TokenType.Bot, _config.Token).Wait();
  29. MigrateAsync().Wait();
  30. _guild = _client.GetGuildAsync(_config.GuildId).Result;
  31. }
  32. public void Dispose()
  33. {
  34. _client.Dispose();
  35. _cache.Dispose();
  36. }
  37. }
  38. public partial class Tests : IClassFixture<TestsFixture>
  39. {
  40. private DiscordRestClient _client;
  41. private RestGuild _guild;
  42. public Tests(TestsFixture fixture)
  43. {
  44. _client = fixture._client;
  45. _guild = fixture._guild;
  46. }
  47. }
  48. }
  49. #endif