Browse Source

Create basic skeleton for REST testing

pull/279/head
Christopher F 8 years ago
parent
commit
57a2cf71b0
6 changed files with 144 additions and 0 deletions
  1. +19
    -0
      test/Discord.Net.Tests/Discord.Net.Tests.xproj
  2. +40
    -0
      test/Discord.Net.Tests/Framework/MockRestClient.cs
  3. +20
    -0
      test/Discord.Net.Tests/Rest/LoginTests.cs
  4. +24
    -0
      test/Discord.Net.Tests/Rest/RestFixture.cs
  5. +14
    -0
      test/Discord.Net.Tests/Tests.cs
  6. +27
    -0
      test/Discord.Net.Tests/project.json

+ 19
- 0
test/Discord.Net.Tests/Discord.Net.Tests.xproj View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.25420" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.25420</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>69eecb8d-8705-424f-9202-f7f4051ee403</ProjectGuid>
<RootNamespace>Discord.Net.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
</PropertyGroup>

<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

+ 40
- 0
test/Discord.Net.Tests/Framework/MockRestClient.cs View File

@@ -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<Stream> IRestClient.SendAsync(string method, string endpoint, bool headerOnly)
{
throw new NotImplementedException();
}

Task<Stream> IRestClient.SendAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartParams, bool headerOnly)
{
throw new NotImplementedException();
}

Task<Stream> 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();
}
}
}

+ 20
- 0
test/Discord.Net.Tests/Rest/LoginTests.cs View File

@@ -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<RestFixture>
{
DiscordRestClient client;

public LoginTests(RestFixture fixture)
{
client = fixture.Client;
}
}
}

+ 24
- 0
test/Discord.Net.Tests/Rest/RestFixture.cs View File

@@ -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();
}
}
}

+ 14
- 0
test/Discord.Net.Tests/Tests.cs View File

@@ -0,0 +1,14 @@
using System;
using Xunit;

namespace Tests
{
public class Tests
{
[Fact]
public void Test1()
{
Assert.True(true);
}
}
}

+ 27
- 0
test/Discord.Net.Tests/project.json View File

@@ -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"
]
}
}
}

Loading…
Cancel
Save