Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename tests add derived interface test #1816

Merged
merged 3 commits into from
Sep 17, 2024
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
20 changes: 18 additions & 2 deletions Refit.GeneratorTests/InterfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface IContainedInterface
}

[Fact]
public Task DerivedRefitInterfaceTest()
public Task RefitInterfaceDerivedFromRefitBaseTest()
{
return Fixture.VerifyForType(
"""
Expand All @@ -38,8 +38,9 @@ public interface IBaseInterface
}

[Fact]
public Task DerivedNonRefitInterfaceTest()
public Task RefitInterfaceDerivedFromBaseTest()
{
// this currently generates invalid code see issue #1801 for more information
return Fixture.VerifyForType(
"""
public interface IGeneratedInterface : IBaseInterface
Expand All @@ -55,6 +56,21 @@ public interface IBaseInterface
""");
}

[Fact]
public Task InterfaceDerivedFromRefitBaseTest()
{
return Fixture.VerifyForType(
"""
public interface IBaseInterface
{
[Get("/users")]
Task<string> Get();
}

public interface IDerivedInterface : IBaseInterface { }
""");
}

[Fact]
public Task NestedNamespaceTest()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: IGeneratedClient.g.cs
//HintName: IBaseInterface.g.cs
#nullable disable
#pragma warning disable
namespace Refit.Implementation
Expand All @@ -13,16 +13,16 @@ partial class Generated
[global::RefitInternalGenerated.PreserveAttribute]
[global::System.Reflection.Obfuscation(Exclude=true)]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
partial class RefitGeneratorTestIGeneratedClient
: global::RefitGeneratorTest.IGeneratedClient
partial class RefitGeneratorTestIBaseInterface
: global::RefitGeneratorTest.IBaseInterface

{
/// <inheritdoc />
public global::System.Net.Http.HttpClient Client { get; }
readonly global::Refit.IRequestBuilder requestBuilder;

/// <inheritdoc />
public RefitGeneratorTestIGeneratedClient(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder)
public RefitGeneratorTestIBaseInterface(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder)
{
Client = client;
this.requestBuilder = requestBuilder;
Expand All @@ -46,7 +46,7 @@ public RefitGeneratorTestIGeneratedClient(global::System.Net.Http.HttpClient cli
}

/// <inheritdoc />
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get()
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IBaseInterface.Get()
{
var ______arguments = global::System.Array.Empty<object>();
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//HintName: IDerivedInterface.g.cs
#nullable disable
#pragma warning disable
namespace Refit.Implementation
{

partial class Generated
{

/// <inheritdoc />
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
[global::System.Diagnostics.DebuggerNonUserCode]
[global::RefitInternalGenerated.PreserveAttribute]
[global::System.Reflection.Obfuscation(Exclude=true)]
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
partial class RefitGeneratorTestIDerivedInterface
: global::RefitGeneratorTest.IDerivedInterface

{
/// <inheritdoc />
public global::System.Net.Http.HttpClient Client { get; }
readonly global::Refit.IRequestBuilder requestBuilder;

/// <inheritdoc />
public RefitGeneratorTestIDerivedInterface(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder)
{
Client = client;
this.requestBuilder = requestBuilder;
}



/// <inheritdoc />
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IBaseInterface.Get()
{
var ______arguments = global::System.Array.Empty<object>();
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() );
try
{
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false);
}
catch (global::System.Exception ______ex)
{
throw ______ex;
}
}
}
}
}

#pragma warning restore
Loading