-
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added nullable and parameter tests (#1863)
Co-authored-by: Chris Pulman <chris.pulman@yahoo.com>
- Loading branch information
1 parent
9b19657
commit 606a6c6
Showing
8 changed files
with
398 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
namespace Refit.GeneratorTests; | ||
|
||
public class ParameterTests | ||
{ | ||
[Fact] | ||
public Task RouteParameter() | ||
{ | ||
return Fixture.VerifyForBody( | ||
""" | ||
[Get("/users/{user}")] | ||
Task<string> Get(string user); | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task NullableRouteParameter() | ||
{ | ||
return Fixture.VerifyForBody( | ||
""" | ||
[Get("/users/{user}")] | ||
Task<string> Get(string? user); | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task ValueTypeRouteParameter() | ||
{ | ||
return Fixture.VerifyForBody( | ||
""" | ||
[Get("/users/{user}")] | ||
Task<string> Get(int user); | ||
"""); | ||
} | ||
|
||
[Fact] | ||
public Task NullableValueTypeRouteParameter() | ||
{ | ||
return Fixture.VerifyForBody( | ||
""" | ||
[Get("/users/{user}")] | ||
Task<string> Get(int? user); | ||
"""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...atorTests/_snapshots/ParameterTests.NullableRouteParameter#IGeneratedClient.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//HintName: IGeneratedClient.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 RefitGeneratorTestIGeneratedClient | ||
: global::RefitGeneratorTest.IGeneratedClient | ||
|
||
{ | ||
/// <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) | ||
{ | ||
Client = client; | ||
this.requestBuilder = requestBuilder; | ||
} | ||
|
||
|
||
private static readonly global::System.Type[] ______typeParameters = new global::System.Type[] {typeof(string) }; | ||
|
||
/// <inheritdoc /> | ||
public async global::System.Threading.Tasks.Task<string> Get(string? @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
|
||
private static readonly global::System.Type[] ______typeParameters0 = new global::System.Type[] {typeof(string) }; | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get(string? @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters0 ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
57 changes: 57 additions & 0 deletions
57
.../_snapshots/ParameterTests.NullableValueTypeRouteParameter#IGeneratedClient.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//HintName: IGeneratedClient.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 RefitGeneratorTestIGeneratedClient | ||
: global::RefitGeneratorTest.IGeneratedClient | ||
|
||
{ | ||
/// <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) | ||
{ | ||
Client = client; | ||
this.requestBuilder = requestBuilder; | ||
} | ||
|
||
|
||
private static readonly global::System.Type[] ______typeParameters = new global::System.Type[] {typeof(int?) }; | ||
|
||
/// <inheritdoc /> | ||
public async global::System.Threading.Tasks.Task<string> Get(int? @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
|
||
private static readonly global::System.Type[] ______typeParameters0 = new global::System.Type[] {typeof(int?) }; | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get(int? @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters0 ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
57 changes: 57 additions & 0 deletions
57
Refit.GeneratorTests/_snapshots/ParameterTests.RouteParameter#IGeneratedClient.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//HintName: IGeneratedClient.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 RefitGeneratorTestIGeneratedClient | ||
: global::RefitGeneratorTest.IGeneratedClient | ||
|
||
{ | ||
/// <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) | ||
{ | ||
Client = client; | ||
this.requestBuilder = requestBuilder; | ||
} | ||
|
||
|
||
private static readonly global::System.Type[] ______typeParameters = new global::System.Type[] {typeof(string) }; | ||
|
||
/// <inheritdoc /> | ||
public async global::System.Threading.Tasks.Task<string> Get(string @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
|
||
private static readonly global::System.Type[] ______typeParameters0 = new global::System.Type[] {typeof(string) }; | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get(string @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters0 ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
57 changes: 57 additions & 0 deletions
57
...torTests/_snapshots/ParameterTests.ValueTypeRouteParameter#IGeneratedClient.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
//HintName: IGeneratedClient.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 RefitGeneratorTestIGeneratedClient | ||
: global::RefitGeneratorTest.IGeneratedClient | ||
|
||
{ | ||
/// <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) | ||
{ | ||
Client = client; | ||
this.requestBuilder = requestBuilder; | ||
} | ||
|
||
|
||
private static readonly global::System.Type[] ______typeParameters = new global::System.Type[] {typeof(int) }; | ||
|
||
/// <inheritdoc /> | ||
public async global::System.Threading.Tasks.Task<string> Get(int @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
|
||
private static readonly global::System.Type[] ______typeParameters0 = new global::System.Type[] {typeof(int) }; | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get(int @user) | ||
{ | ||
var ______arguments = new object[] { @user }; | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", ______typeParameters0 ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
53 changes: 53 additions & 0 deletions
53
...ratorTests/_snapshots/ReturnTypeTests.ReturnNullableObject#IGeneratedClient.g.verified.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//HintName: IGeneratedClient.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 RefitGeneratorTestIGeneratedClient | ||
: global::RefitGeneratorTest.IGeneratedClient | ||
|
||
{ | ||
/// <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) | ||
{ | ||
Client = client; | ||
this.requestBuilder = requestBuilder; | ||
} | ||
|
||
|
||
/// <inheritdoc /> | ||
public async global::System.Threading.Tasks.Task<string> Get() | ||
{ | ||
var ______arguments = global::System.Array.Empty<object>(); | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
|
||
/// <inheritdoc /> | ||
async global::System.Threading.Tasks.Task<string> global::RefitGeneratorTest.IGeneratedClient.Get() | ||
{ | ||
var ______arguments = global::System.Array.Empty<object>(); | ||
var ______func = requestBuilder.BuildRestResultFuncForMethod("Get", global::System.Array.Empty<global::System.Type>() ); | ||
|
||
return await ((global::System.Threading.Tasks.Task<string>)______func(this.Client, ______arguments)).ConfigureAwait(false); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#pragma warning restore |
Oops, something went wrong.