Skip to content

Commit 6a48f72

Browse files
committed
Test cleanup.
1 parent 75a1618 commit 6a48f72

9 files changed

Lines changed: 182 additions & 200 deletions

test/Autofac.Pooling.Test/ConcurrencyTests.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ public async Task CanUsePoolConcurrently()
1313
{
1414
var builder = new ContainerBuilder();
1515

16-
builder.RegisterType<PooledComponent>().As<IPooledService>()
17-
.PooledInstancePerLifetimeScope();
16+
builder.RegisterType<PooledComponent>()
17+
.As<IPooledService>()
18+
.PooledInstancePerLifetimeScope();
1819

1920
var container = builder.Build();
2021

@@ -39,8 +40,9 @@ public async Task CanUsePoolConcurrentlyWithCustomPolicyToBlockOnMaxUsage()
3940

4041
using var blockingPolicy = new BlockingPolicy<PooledComponent>(4);
4142

42-
builder.RegisterType<PooledComponent>().As<IPooledService>()
43-
.PooledInstancePerLifetimeScope(blockingPolicy);
43+
builder.RegisterType<PooledComponent>()
44+
.As<IPooledService>()
45+
.PooledInstancePerLifetimeScope(blockingPolicy);
4446

4547
var container = builder.Build();
4648

test/Autofac.Pooling.Test/CustomProviderTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ public void Provider_DisposableCustomPoolDisposedAtShutdown()
292292
}
293293

294294
[Fact]
295-
public void Provider_NullProviderFactoryThrows()
295+
public void Provider_NullProviderFactory()
296296
{
297297
var builder = new ContainerBuilder();
298298

@@ -305,7 +305,7 @@ public void Provider_NullProviderFactoryThrows()
305305
}
306306

307307
[Fact]
308-
public void Provider_NullProviderFactoryWithPolicyThrows()
308+
public void Provider_NullProviderFactoryWithPolicy()
309309
{
310310
var builder = new ContainerBuilder();
311311

@@ -315,11 +315,11 @@ public void Provider_NullProviderFactoryWithPolicyThrows()
315315
Assert.Throws<ArgumentNullException>(() =>
316316
reg.PooledInstancePerLifetimeScope(
317317
ctx => new DefaultPooledRegistrationPolicy<PooledComponent>(),
318-
(Func<IComponentContext, ObjectPoolProvider>)null!));
318+
null!));
319319
}
320320

321321
[Fact]
322-
public void Provider_NullPolicyFactoryWithProviderThrows()
322+
public void Provider_NullPolicyFactoryWithProvider()
323323
{
324324
var builder = new ContainerBuilder();
325325

@@ -328,12 +328,12 @@ public void Provider_NullPolicyFactoryWithProviderThrows()
328328

329329
Assert.Throws<ArgumentNullException>(() =>
330330
reg.PooledInstancePerLifetimeScope(
331-
(Func<IComponentContext, IPooledRegistrationPolicy<PooledComponent>>)null!,
331+
null!,
332332
ctx => new TrackingObjectPoolProvider()));
333333
}
334334

335335
[Fact]
336-
public void Provider_NullProviderFactoryWithMatchingScopeThrows()
336+
public void Provider_NullProviderFactoryWithMatchingScope()
337337
{
338338
var builder = new ContainerBuilder();
339339

test/Autofac.Pooling.Test/DefaultPooledRegistrationPolicyTests.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,38 @@ namespace Autofac.Pooling.Test;
88
public class DefaultPooledRegistrationPolicyTests
99
{
1010
[Fact]
11-
public void DefaultConstructorUsesTwiceProcessorCount()
11+
public void Ctor_MaximumRetainedUsesSuppliedValue()
1212
{
13-
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>();
13+
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>(3);
1414

15-
Assert.Equal(Environment.ProcessorCount * 2, policy.MaximumRetained);
15+
Assert.Equal(3, policy.MaximumRetained);
1616
}
1717

1818
[Fact]
19-
public void MaximumRetainedConstructorUsesSuppliedValue()
19+
public void Ctor_MaximumRetainedUsesTwiceProcessorCount()
2020
{
21-
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>(3);
21+
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>();
2222

23-
Assert.Equal(3, policy.MaximumRetained);
23+
Assert.Equal(Environment.ProcessorCount * 2, policy.MaximumRetained);
2424
}
2525

2626
[Fact]
27-
public void ZeroMaximumRetainedIsAllowed()
27+
public void Ctor_ZeroMaximumRetainedIsAllowed()
2828
{
2929
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>(0);
3030

3131
Assert.Equal(0, policy.MaximumRetained);
3232
}
3333

3434
[Fact]
35-
public void NegativeMaximumRetainedThrows()
35+
public void Ctor_NegativeMaximumRetainedThrows()
3636
{
3737
Assert.Throws<ArgumentOutOfRangeException>(() =>
3838
new DefaultPooledRegistrationPolicy<PooledComponent>(-1));
3939
}
4040

4141
[Fact]
42-
public void GetInvokesTheGetFromPoolCallback()
42+
public void Get_InvokesTheGetFromPoolCallback()
4343
{
4444
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>();
4545
using var expected = new PooledComponent();
@@ -50,7 +50,7 @@ public void GetInvokesTheGetFromPoolCallback()
5050
}
5151

5252
[Fact]
53-
public void GetWithNullGetFromPoolThrows()
53+
public void Get_NullGetFromPool()
5454
{
5555
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>();
5656

@@ -59,7 +59,7 @@ public void GetWithNullGetFromPoolThrows()
5959
}
6060

6161
[Fact]
62-
public void ReturnAlwaysAcceptsTheInstance()
62+
public void Return_AlwaysAcceptsTheInstance()
6363
{
6464
var policy = new DefaultPooledRegistrationPolicy<PooledComponent>();
6565
using var instance = new PooledComponent();

test/Autofac.Pooling.Test/Examples/Caching/ConnectionConsumer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Autofac Project. All rights reserved.
1+
// Copyright (c) Autofac Project. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
namespace Autofac.Pooling.Test.Examples.Caching;

test/Autofac.Pooling.Test/Examples/Caching/MyCustomConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Autofac Project. All rights reserved.
1+
// Copyright (c) Autofac Project. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using Autofac.Core;

test/Autofac.Pooling.Test/FactoryOverloadTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public void PolicyFactory_DisposableRegistrationsDisposedWhenContainerIsDisposed
208208
}
209209

210210
[Fact]
211-
public void PolicyFactory_NullPolicyFactoryThrows()
211+
public void PolicyFactory_NullPolicyFactory()
212212
{
213213
var builder = new ContainerBuilder();
214214

@@ -221,7 +221,7 @@ public void PolicyFactory_NullPolicyFactoryThrows()
221221
}
222222

223223
[Fact]
224-
public void PolicyFactory_NullPolicyFactoryWithMatchingScopeThrows()
224+
public void PolicyFactory_NullPolicyFactoryWithMatchingScope()
225225
{
226226
var builder = new ContainerBuilder();
227227

test/Autofac.Pooling.Test/PoolServiceTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Autofac.Pooling.Test;
99
public class PoolServiceTests
1010
{
1111
[Fact]
12-
public void DescriptionIncludesTheLimitType()
12+
public void Ctor_DescriptionIncludesTheLimitType()
1313
{
1414
var registration = RegistrationFor<PooledComponent>();
1515

@@ -19,7 +19,7 @@ public void DescriptionIncludesTheLimitType()
1919
}
2020

2121
[Fact]
22-
public void EqualsIsTrueForTheSameUnderlyingRegistration()
22+
public void Equals_SameUnderlyingRegistration()
2323
{
2424
var registration = RegistrationFor<PooledComponent>();
2525

@@ -31,7 +31,7 @@ public void EqualsIsTrueForTheSameUnderlyingRegistration()
3131
}
3232

3333
[Fact]
34-
public void EqualsIsFalseForDifferentRegistrations()
34+
public void Equals_DifferentRegistrations()
3535
{
3636
var first = new PoolService(RegistrationFor<PooledComponent>());
3737
var second = new PoolService(RegistrationFor<OtherPooledComponent>());
@@ -40,7 +40,7 @@ public void EqualsIsFalseForDifferentRegistrations()
4040
}
4141

4242
[Fact]
43-
public void EqualsObjectMatchesAnotherPoolService()
43+
public void EqualsObject_MatchesAnotherPoolService()
4444
{
4545
var registration = RegistrationFor<PooledComponent>();
4646

@@ -51,7 +51,7 @@ public void EqualsObjectMatchesAnotherPoolService()
5151
}
5252

5353
[Fact]
54-
public void EqualsObjectIsFalseForUnrelatedType()
54+
public void EqualsObject_UnrelatedType()
5555
{
5656
var service = new PoolService(RegistrationFor<PooledComponent>());
5757

@@ -60,7 +60,7 @@ public void EqualsObjectIsFalseForUnrelatedType()
6060

6161
[Fact]
6262
[SuppressMessage("CA1508", "CA1508", Justification = "Deliberately exercising the Equals null branch for coverage.")]
63-
public void EqualsIsFalseForNull()
63+
public void EqualsObject_Null()
6464
{
6565
var service = new PoolService(RegistrationFor<PooledComponent>());
6666

test/Autofac.Pooling.Test/RegistrationExtensionsNullGuardTests.cs

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)