Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions RestSharp.Tests/InterfaceImplementationTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
namespace RestSharp.Tests
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Xunit;

public class InterfaceImplementationTests
{
[Fact]
public void IRestSharp_Has_All_RestSharp_Signatures()
{
// Arrange
var restClientImplementationType = typeof(RestClient);
var restClientInterfaceType = typeof(IRestClient);
var bindingFlags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly;

// Act
IEnumerable<string> compareResult = CompareTypes(restClientImplementationType, restClientInterfaceType, bindingFlags);
compareResult.ToList().ForEach(x => Console.WriteLine("Method {0} exists in {1} but not in {2}", x, restClientImplementationType.FullName, restClientInterfaceType.FullName));

// Assert
Assert.Equal(0, compareResult.Count());
}

private static IEnumerable<string> CompareTypes(Type type1, Type type2, BindingFlags bindingFlags)
{
MethodInfo[] typeTMethodInfo = type1.GetMethods(bindingFlags);
MethodInfo[] typeXMethodInfo = type2.GetMethods(bindingFlags);

return typeTMethodInfo.Select(x => x.Name).Except(typeXMethodInfo.Select(x => x.Name));
}
}
}
1 change: 1 addition & 0 deletions RestSharp.Tests/RestSharp.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InterfaceImplementationTests.cs" />
<Compile Include="OAuthTests.cs" />
<Compile Include="SampleClasses\EmployeeTracker.cs" />
<Compile Include="SampleClasses\EnumTest.cs" />
Expand Down
13 changes: 13 additions & 0 deletions RestSharp/IRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using RestSharp.Deserializers;

#if NET4 || MONODROID || MONOTOUCH || WP8
using System.Threading;
Expand All @@ -32,6 +33,8 @@ public interface IRestClient
#if !PocketPC
CookieContainer CookieContainer { get; set; }
#endif
int? MaxRedirects { get; set; }

string UserAgent { get; set; }

int Timeout { get; set; }
Expand All @@ -58,6 +61,8 @@ public interface IRestClient
IRestResponse Execute(IRestRequest request);

IRestResponse<T> Execute<T>(IRestRequest request) where T : new();

byte[] DownloadData(IRestRequest request);
#endif

#if FRAMEWORK
Expand All @@ -69,6 +74,8 @@ public interface IRestClient
IWebProxy Proxy { get; set; }
#endif

bool FollowRedirects { get; set; }

Uri BuildUri(IRestRequest request);

/// <summary>
Expand Down Expand Up @@ -105,6 +112,12 @@ public interface IRestClient
/// <param name="httpMethod">The HTTP method to execute</param>
RestRequestAsyncHandle ExecuteAsyncPost<T>(IRestRequest request, Action<IRestResponse<T>, RestRequestAsyncHandle> callback, string httpMethod);

void AddHandler(string contentType, IDeserializer deserializer);

void RemoveHandler(string contentType);

void ClearHandlers();

#if FRAMEWORK
IRestResponse ExecuteAsGet(IRestRequest request, string httpMethod);

Expand Down