2 implementations of ITestClass
Microsoft.Extensions.ObjectPool.DependencyInjection.Tests (2)
TestResources\OtherTestClass.cs (1)
8
public class OtherTestClass :
ITestClass
TestResources\TestClass.cs (1)
9
public sealed class TestClass : IResettable, IDisposable,
ITestClass
46 references to ITestClass
Microsoft.Extensions.ObjectPool.DependencyInjection.Tests (46)
DependencyInjectionExtensionsTests.cs (43)
20
Assert.Throws<ArgumentNullException>(() => ObjectPoolServiceCollectionExtensions.AddPooled<
ITestClass
, TestClass>(null!));
100
.AddPooled<
ITestClass
, TestClass>()
101
.AddPooled<
ITestClass
, OtherTestClass>();
104
var pool = provider.GetRequiredService<ObjectPool<
ITestClass
>>();
106
var
pooled = pool.Get();
130
.AddPooled<
ITestClass
, TestClass>();
133
var pool = provider.GetService<ObjectPool<
ITestClass
>>();
144
.AddPooled<
ITestClass
, TestClass>(options => options.Capacity = 64);
147
var pool = provider.GetService<ObjectPool<
ITestClass
>>();
152
Assert.Equal(64, optionsMonitor.Get(typeof(
ITestClass
).FullName).Capacity);
160
.AddPooled<
ITestClass
, TestClass>();
163
var pool = provider.GetRequiredService<ObjectPool<
ITestClass
>>();
165
var
pooled = pool.Get();
179
.AddPooled<
ITestClass
, TestClass>(options => options.Capacity = capacity);
182
var pool = provider.GetRequiredService<ObjectPool<
ITestClass
>>();
184
var instances = new
ITestClass
[capacity];
198
var
pooled = pool.Get();
202
var
newPooled = pool.Get();
214
.AddPooled<
ITestClass
, TestClass>();
217
Assert.Throws<InvalidOperationException>(() => provider.GetRequiredService<ObjectPool<
ITestClass
>>().Get());
227
.AddScoped<
ITestClass
>(provider => provider.GetRequiredService<Pooled<TestClass>>().Object)
232
ITestClass
resolved1;
233
ITestClass
resolved2;
240
resolved1 = scope.ServiceProvider.GetRequiredService<
ITestClass
>();
241
resolved2 = scope.ServiceProvider.GetRequiredService<
ITestClass
>();
262
.AddTransient<
ITestClass
>(provider => provider.GetRequiredService<Pooled<TestClass>>().Object)
267
ITestClass
resolved1;
268
ITestClass
resolved2;
269
ITestClass
resolved3;
270
ITestClass
resolved4;
273
resolved1 = scope1.ServiceProvider.GetRequiredService<
ITestClass
>();
274
resolved2 = scope1.ServiceProvider.GetRequiredService<
ITestClass
>();
277
resolved3 = scope2.ServiceProvider.GetRequiredService<
ITestClass
>();
278
resolved4 = scope2.ServiceProvider.GetRequiredService<
ITestClass
>();
319
.AddScoped<
ITestClass
>(provider => provider.GetRequiredService<Pooled<TestClass>>().Object)
324
ITestClass
resolved1;
325
ITestClass
resolved2;
326
ITestClass
resolved3;
327
ITestClass
resolved4;
330
resolved1 = scope1.ServiceProvider.GetRequiredService<
ITestClass
>();
331
resolved2 = scope1.ServiceProvider.GetRequiredService<
ITestClass
>();
334
resolved3 = scope2.ServiceProvider.GetRequiredService<
ITestClass
>();
335
resolved4 = scope2.ServiceProvider.GetRequiredService<
ITestClass
>();
TestResources\OtherTestClass.cs (3)
10
int
ITestClass
.ResetCalled => throw new NotSupportedException();
12
int
ITestClass
.DisposedCalled => throw new NotSupportedException();
14
string
ITestClass
.ReadMessage()