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