File tree Expand file tree Collapse file tree 3 files changed +5
-8
lines changed
Devlead.Testing.MockHttp.Tests/Unit Expand file tree Collapse file tree 3 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -92,13 +92,8 @@ public async Task Send(params string[] methods)
9292 // When
9393 var result = await methods
9494 . ToAsyncEnumerable ( )
95- #if NET10_0_OR_GREATER
9695 . Select (
9796 async ( method , _ , _ )
98- #else
99- . SelectAwait (
100- async method
101- #endif
10297 => await httpClient . SendAsync (
10398 new HttpRequestMessage (
10499 new HttpMethod ( method ) ,
Original file line number Diff line number Diff line change @@ -11,9 +11,11 @@ public static IServiceCollection AddMockHttpClient<T>(
1111 this IServiceCollection services
1212 )
1313 {
14+ services . AddSingleton ( Routes < T > . GetResponseBuilder ) ;
15+
1416 static MockHttpClient CreateClient ( IServiceProvider provider )
1517 {
16- var client = new MockHttpClient ( Routes < T > . GetResponseBuilder ( provider ) ) ;
18+ var client = new MockHttpClient ( provider . GetRequiredService < Func < HttpRequestMessage , HttpResponseMessage > > ( ) ) ;
1719 foreach ( var service in provider . GetServices < ConfigureHttpClient < T > > ( ) )
1820 {
1921 service ? . Invoke ( client ) ;
@@ -22,7 +24,7 @@ static MockHttpClient CreateClient(IServiceProvider provider)
2224 }
2325
2426 static MockHttpMessageHandlerFactory CreateHttpMessageHandlerFactory ( IServiceProvider provider )
25- => new ( Routes < T > . GetResponseBuilder ( provider ) ) ;
27+ => new ( provider . GetRequiredService < Func < HttpRequestMessage , HttpResponseMessage > > ( ) ) ;
2628
2729 return services
2830 . AddTransient < HttpClient > ( provider => provider . GetRequiredService < MockHttpClient > ( ) )
Original file line number Diff line number Diff line change 1717 <PackageVersion Include =" NUnit" Version =" 4.4.0" />
1818 <PackageVersion Include =" NUnit.Analyzers" Version =" 4.11.2" />
1919 <PackageVersion Include =" NUnit3TestAdapter" Version =" 5.2.0" />
20- <PackageVersion Include =" System.Linq.Async" Version =" 6 .0.3 " />
20+ <PackageVersion Include =" System.Linq.Async" Version =" 7 .0.0 " />
2121 <PackageVersion Include =" Verify.NUnit" Version =" 31.7.2" />
2222 <PackageVersion Include =" Verify.Http" Version =" 7.5.0" />
2323 <PackageVersion Include =" System.Text.Json" Version =" 9.0.11" />
You can’t perform that action at this time.
0 commit comments