|
|
@@ -4,37 +4,42 @@ using System.IO; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Discord.Net.Rest; |
|
|
|
using System.Collections.ObjectModel; |
|
|
|
|
|
|
|
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(); |
|
|
|
_requestHandler = new RequestHandler(); |
|
|
|
} |
|
|
|
|
|
|
|
Task<Stream> IRestClient.SendAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartParams, bool headerOnly) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
private Dictionary<string, string> _headers = new Dictionary<string, string>(); |
|
|
|
public IReadOnlyDictionary<string, string> Headers => |
|
|
|
new ReadOnlyDictionary<string, string>(_headers); |
|
|
|
private RequestHandler _requestHandler; |
|
|
|
|
|
|
|
Task<Stream> IRestClient.SendAsync(string method, string endpoint, string json, bool headerOnly) |
|
|
|
public Task<Stream> SendAsync(string method, string endpoint, bool headerOnly = false) => |
|
|
|
SendAsync(method, endpoint, "", headerOnly); |
|
|
|
|
|
|
|
public Task<Stream> SendAsync(string method, string endpoint, IReadOnlyDictionary<string, object> multipartParams, bool headerOnly = false) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
} |
|
|
|
|
|
|
|
void IRestClient.SetCancelToken(CancellationToken cancelToken) |
|
|
|
public Task<Stream> SendAsync(string method, string endpoint, string json, bool headerOnly = false) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
return Task.FromResult(_requestHandler.GetMock(method, endpoint, json, Headers)); |
|
|
|
} |
|
|
|
|
|
|
|
void IRestClient.SetHeader(string key, string value) |
|
|
|
public void SetCancelToken(CancellationToken cancelToken) { } |
|
|
|
|
|
|
|
public void SetHeader(string key, string value) |
|
|
|
{ |
|
|
|
throw new NotImplementedException(); |
|
|
|
if (_headers.ContainsKey(key)) |
|
|
|
_headers.Remove(key); |
|
|
|
_headers.Add(key, value); |
|
|
|
} |
|
|
|
} |
|
|
|
} |