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.3 KiB

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