Skip to content

Commit 5331648

Browse files
test: add IObservable generator test (#1960)
Co-authored-by: Chris Pulman <[email protected]>
1 parent e954c18 commit 5331648

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

Refit.GeneratorTests/ReturnTypeTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,14 @@ public Task GenericStructConstraintReturnTask()
7171
Task<string> Get<T>() where T : struct
7272
""");
7373
}
74+
75+
[Fact]
76+
public Task ReturnIObservable()
77+
{
78+
return Fixture.VerifyForBody(
79+
"""
80+
[Get("/users/{user}")]
81+
IObservable<HttpResponseMessage> GetUser(string user);
82+
""");
83+
}
7484
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//HintName: IGeneratedClient.g.cs
2+
#nullable disable
3+
#pragma warning disable
4+
namespace Refit.Implementation
5+
{
6+
7+
partial class Generated
8+
{
9+
10+
/// <inheritdoc />
11+
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
12+
[global::System.Diagnostics.DebuggerNonUserCode]
13+
[global::RefitInternalGenerated.PreserveAttribute]
14+
[global::System.Reflection.Obfuscation(Exclude=true)]
15+
[global::System.ComponentModel.EditorBrowsable(global::System.ComponentModel.EditorBrowsableState.Never)]
16+
partial class RefitGeneratorTestIGeneratedClient
17+
: global::RefitGeneratorTest.IGeneratedClient
18+
19+
{
20+
/// <inheritdoc />
21+
public global::System.Net.Http.HttpClient Client { get; }
22+
readonly global::Refit.IRequestBuilder requestBuilder;
23+
24+
/// <inheritdoc />
25+
public RefitGeneratorTestIGeneratedClient(global::System.Net.Http.HttpClient client, global::Refit.IRequestBuilder requestBuilder)
26+
{
27+
Client = client;
28+
this.requestBuilder = requestBuilder;
29+
}
30+
31+
32+
private static readonly global::System.Type[] ______typeParameters = new global::System.Type[] {typeof(string) };
33+
34+
/// <inheritdoc />
35+
public global::System.IObservable<global::System.Net.Http.HttpResponseMessage> GetUser(string @user)
36+
{
37+
var ______arguments = new object[] { @user };
38+
var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", ______typeParameters );
39+
40+
return (global::System.IObservable<global::System.Net.Http.HttpResponseMessage>)______func(this.Client, ______arguments);
41+
}
42+
43+
private static readonly global::System.Type[] ______typeParameters0 = new global::System.Type[] {typeof(string) };
44+
45+
/// <inheritdoc />
46+
global::System.IObservable<global::System.Net.Http.HttpResponseMessage> global::RefitGeneratorTest.IGeneratedClient.GetUser(string @user)
47+
{
48+
var ______arguments = new object[] { @user };
49+
var ______func = requestBuilder.BuildRestResultFuncForMethod("GetUser", ______typeParameters0 );
50+
51+
return (global::System.IObservable<global::System.Net.Http.HttpResponseMessage>)______func(this.Client, ______arguments);
52+
}
53+
}
54+
}
55+
}
56+
57+
#pragma warning restore

0 commit comments

Comments
 (0)