From 57a2cf71b065adde9c4d4a2565685e1b4c673cff Mon Sep 17 00:00:00 2001 From: Christopher F Date: Wed, 7 Sep 2016 18:10:30 -0400 Subject: [PATCH] Create basic skeleton for REST testing --- .../Discord.Net.Tests/Discord.Net.Tests.xproj | 19 +++++++++ .../Framework/MockRestClient.cs | 40 +++++++++++++++++++ test/Discord.Net.Tests/Rest/LoginTests.cs | 20 ++++++++++ test/Discord.Net.Tests/Rest/RestFixture.cs | 24 +++++++++++ test/Discord.Net.Tests/Tests.cs | 14 +++++++ test/Discord.Net.Tests/project.json | 27 +++++++++++++ 6 files changed, 144 insertions(+) create mode 100644 test/Discord.Net.Tests/Discord.Net.Tests.xproj create mode 100644 test/Discord.Net.Tests/Framework/MockRestClient.cs create mode 100644 test/Discord.Net.Tests/Rest/LoginTests.cs create mode 100644 test/Discord.Net.Tests/Rest/RestFixture.cs create mode 100644 test/Discord.Net.Tests/Tests.cs create mode 100644 test/Discord.Net.Tests/project.json diff --git a/test/Discord.Net.Tests/Discord.Net.Tests.xproj b/test/Discord.Net.Tests/Discord.Net.Tests.xproj new file mode 100644 index 000000000..1177c8fb2 --- /dev/null +++ b/test/Discord.Net.Tests/Discord.Net.Tests.xproj @@ -0,0 +1,19 @@ + + + + 14.0.25420 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 69eecb8d-8705-424f-9202-f7f4051ee403 + Discord.Net.Tests + .\obj + .\bin\ + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Discord.Net.Tests/Framework/MockRestClient.cs b/test/Discord.Net.Tests/Framework/MockRestClient.cs new file mode 100644 index 000000000..3450f0f94 --- /dev/null +++ b/test/Discord.Net.Tests/Framework/MockRestClient.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using Discord.Net.Rest; + +namespace Discord.Tests.Framework +{ + public class MockRestClient : IRestClient + { + public MockRestClient(string baseUrl) + { } + + Task IRestClient.SendAsync(string method, string endpoint, bool headerOnly) + { + throw new NotImplementedException(); + } + + Task IRestClient.SendAsync(string method, string endpoint, IReadOnlyDictionary multipartParams, bool headerOnly) + { + throw new NotImplementedException(); + } + + Task IRestClient.SendAsync(string method, string endpoint, string json, bool headerOnly) + { + throw new NotImplementedException(); + } + + void IRestClient.SetCancelToken(CancellationToken cancelToken) + { + throw new NotImplementedException(); + } + + void IRestClient.SetHeader(string key, string value) + { + throw new NotImplementedException(); + } + } +} diff --git a/test/Discord.Net.Tests/Rest/LoginTests.cs b/test/Discord.Net.Tests/Rest/LoginTests.cs new file mode 100644 index 000000000..1655b654d --- /dev/null +++ b/test/Discord.Net.Tests/Rest/LoginTests.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Xunit; +using Discord; +using Discord.Rest; + +namespace Discord.Tests.Rest +{ + public class LoginTests : IClassFixture + { + DiscordRestClient client; + + public LoginTests(RestFixture fixture) + { + client = fixture.Client; + } + } +} diff --git a/test/Discord.Net.Tests/Rest/RestFixture.cs b/test/Discord.Net.Tests/Rest/RestFixture.cs new file mode 100644 index 000000000..7959696f9 --- /dev/null +++ b/test/Discord.Net.Tests/Rest/RestFixture.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Discord.Rest; +using Discord.Net.Rest; +using Discord.Tests.Framework; + +namespace Discord.Tests.Rest +{ + public class RestFixture + { + public DiscordRestClient Client { get; set; } + + public RestFixture() + { + var Config = new DiscordRestConfig() + { + RestClientProvider = new RestClientProvider(baseUrl => new MockRestClient(baseUrl)) + }; + Client = new DiscordRestClient(); + } + } +} diff --git a/test/Discord.Net.Tests/Tests.cs b/test/Discord.Net.Tests/Tests.cs new file mode 100644 index 000000000..1bd5ced4f --- /dev/null +++ b/test/Discord.Net.Tests/Tests.cs @@ -0,0 +1,14 @@ +using System; +using Xunit; + +namespace Tests +{ + public class Tests + { + [Fact] + public void Test1() + { + Assert.True(true); + } + } +} diff --git a/test/Discord.Net.Tests/project.json b/test/Discord.Net.Tests/project.json new file mode 100644 index 000000000..96ab1fec9 --- /dev/null +++ b/test/Discord.Net.Tests/project.json @@ -0,0 +1,27 @@ +{ + "version": "1.0.0-*", + "buildOptions": { + "debugType": "portable" + }, + "dependencies": { + "System.Runtime.Serialization.Primitives": "4.1.1", + "xunit": "2.1.0", + "dotnet-test-xunit": "1.0.0-*", + "Discord.Net": "1.0.0-*" + }, + "testRunner": "xunit", + "frameworks": { + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.0" + } + }, + "imports": [ + "dotnet5.4", + "portable-net451+win8" + ] + } + } +}