Skip to content

Commit c8ebad2

Browse files
committed
Added a few unit tests
1 parent 298f90a commit c8ebad2

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

src/ServicePool.Tests/FlexPoolTests.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,38 @@ namespace TheXDS.ServicePool.Tests;
3838
public class FlexPoolTests
3939
{
4040
[Test]
41-
public void Resolve_resolves_for_interfaces()
41+
public void Resolve_with_FlexResolve_resolves_for_interfaces()
4242
{
4343
Pool pool = new(PoolConfig.FlexResolve);
4444
pool.Register<Test1>();
4545
Assert.That(pool.Resolve<ITest>(), Is.Not.Null);
4646
}
4747

4848
[Test]
49-
public void Resolve_resolves_for_base_class()
49+
public void Resolve_with_FlexResolve_resolves_for_base_class()
5050
{
5151
Pool pool = new(PoolConfig.FlexResolve);
5252
pool.Register<Test3>();
5353
Assert.That(pool.Resolve<Test1>(), Is.Not.Null);
5454
}
5555

56+
[Test]
57+
public void Resolve_with_FlexRegister_resolves_for_interfaces()
58+
{
59+
Pool pool = new(PoolConfig.FlexRegister);
60+
pool.Register<Test1>();
61+
Assert.That(pool.Resolve<ITest>(), Is.Not.Null);
62+
}
63+
64+
[Test]
65+
public void Resolve_with_FlexRegister_resolves_for_base_class()
66+
{
67+
Pool pool = new(PoolConfig.FlexRegister);
68+
pool.Register<Test3>();
69+
Assert.That(pool.Resolve<Test1>(), Is.Not.Null);
70+
}
71+
72+
5673
[Test]
5774
public void Discover_searches_for_service()
5875
{

src/ServicePool/PoolConfig.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ public readonly record struct PoolConfig
105105
/// them vary in the kind of services that could be registered.
106106
/// Using <see cref="FlexResolve"/> may allow multiple services that can
107107
/// expose the same service type to be registered, but only the first one
108-
/// to match will be resolved.
108+
/// to match will be resolved. This might be useful when "consuming"
109+
/// services, where each one gets removed from the pool after being
110+
/// resolved.
109111
/// </remarks>
110112
/// /// <seealso cref="FlexRegister"/>
111113
public static readonly PoolConfig FlexResolve = Default with {
@@ -124,7 +126,9 @@ public readonly record struct PoolConfig
124126
/// them vary in the kind of services that could be registered.
125127
/// Using <see cref="FlexRegister"/> will register the specified service
126128
/// type, as well as all of its base classes (except <see cref="object"/>)
127-
/// and implemented interfaces.
129+
/// and implemented interfaces. This will have the effect of disallowing
130+
/// multiple services that can expose the same service type to be
131+
/// registered.
128132
/// </remarks>
129133
/// <seealso cref="FlexResolve"/>
130134
public static readonly PoolConfig FlexRegister = Default with {

0 commit comments

Comments
 (0)