Skip to content

Commit 3f3ee08

Browse files
committed
Renamed Container.Collections to Container.Collection. Related to #556.
1 parent 44bc800 commit 3f3ee08

File tree

8 files changed

+60
-54
lines changed

8 files changed

+60
-54
lines changed

src/SimpleInjector.Tests.Unit/ContainerCollectionAppendToTests.cs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public void AppendTo_WithValidArguments_Suceeds()
1515
var container = ContainerFactory.New();
1616

1717
// Act
18-
container.Collections.AppendTo(typeof(object), CreateRegistration(container));
18+
container.Collection.AppendTo(typeof(object), CreateRegistration(container));
1919
}
2020

2121
[TestMethod]
@@ -28,7 +28,7 @@ public void AppendTo_WithNullServiceTypeArgument_ThrowsException()
2828

2929
// Act
3030
Action action =
31-
() => container.Collections.AppendTo(invalidServiceType, CreateRegistration(container));
31+
() => container.Collection.AppendTo(invalidServiceType, CreateRegistration(container));
3232

3333
// Assert
3434
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceType", action);
@@ -43,7 +43,7 @@ public void AppendTo_WithNullRegistrationArgument_ThrowsException()
4343
Registration invalidRegistration = null;
4444

4545
// Act
46-
Action action = () => container.Collections.AppendTo(typeof(object), invalidRegistration);
46+
Action action = () => container.Collection.AppendTo(typeof(object), invalidRegistration);
4747

4848
// Assert
4949
AssertThat.ThrowsWithParamName<ArgumentNullException>("registration", action);
@@ -60,7 +60,7 @@ public void AppendTo_WithRegistrationForDifferentContainer_ThrowsException()
6060
Registration invalidRegistration = CreateRegistration(differentContainer);
6161

6262
// Act
63-
Action action = () => container.Collections.AppendTo(typeof(object), invalidRegistration);
63+
Action action = () => container.Collection.AppendTo(typeof(object), invalidRegistration);
6464

6565
// Assert
6666
AssertThat.ThrowsWithParamName<ArgumentException>("registration", action);
@@ -76,7 +76,7 @@ public void AppendTo_ForUnregisteredCollection_ResolvesThatRegistrationWhenReque
7676

7777
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
7878

79-
container.Collections.AppendTo(typeof(IPlugin), registration);
79+
container.Collection.AppendTo(typeof(IPlugin), registration);
8080

8181
// Act
8282
var instance = container.GetAllInstances<IPlugin>().Single();
@@ -94,8 +94,8 @@ public void AppendTo_CalledTwice_ResolvesBothRegistrationsWhenRequested()
9494
var registration1 = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
9595
var registration2 = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
9696

97-
container.Collections.AppendTo(typeof(IPlugin), registration1);
98-
container.Collections.AppendTo(typeof(IPlugin), registration2);
97+
container.Collection.AppendTo(typeof(IPlugin), registration1);
98+
container.Collection.AppendTo(typeof(IPlugin), registration2);
9999

100100
// Act
101101
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -115,7 +115,7 @@ public void AppendTo_CalledAfterRegisterCollectionWithTypes_CombinedAllRegistrat
115115

116116
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
117117

118-
container.Collections.AppendTo(typeof(IPlugin), registration);
118+
container.Collection.AppendTo(typeof(IPlugin), registration);
119119

120120
// Act
121121
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -136,7 +136,7 @@ public void AppendTo_CalledAfterRegisterCollectionWithRegistration_CombinedAllRe
136136

137137
container.RegisterCollection(typeof(IPlugin), new[] { registration1 });
138138

139-
container.Collections.AppendTo(typeof(IPlugin), registration2);
139+
container.Collection.AppendTo(typeof(IPlugin), registration2);
140140

141141
// Act
142142
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -155,12 +155,12 @@ public void AppendTo_CalledAfterTheFirstItemIsRequested_ThrowsExpectedException(
155155
var registration1 = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
156156
var registration2 = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
157157

158-
container.Collections.AppendTo(typeof(IPlugin), registration1);
158+
container.Collection.AppendTo(typeof(IPlugin), registration1);
159159

160160
var instances = container.GetAllInstances<IPlugin>().ToArray();
161161

162162
// Act
163-
Action action = () => container.Collections.AppendTo(typeof(IPlugin), registration2);
163+
Action action = () => container.Collection.AppendTo(typeof(IPlugin), registration2);
164164

165165
// Assert
166166
AssertThat.Throws<InvalidOperationException>(action);
@@ -179,7 +179,7 @@ public void AppendTo_OnContainerUncontrolledCollection_ThrowsExpressiveException
179179
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
180180

181181
// Act
182-
Action action = () => container.Collections.AppendTo(typeof(IPlugin), registration);
182+
Action action = () => container.Collection.AppendTo(typeof(IPlugin), registration);
183183

184184
// Assert
185185
AssertThat.ThrowsWithExceptionMessageContains<NotSupportedException>(@"
@@ -205,7 +205,7 @@ public void GetAllInstances_RegistrationAppendedToExistingOpenGenericRegistratio
205205

206206
var registration = Lifestyle.Transient.CreateRegistration<StructEventHandler>(container);
207207

208-
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
208+
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
209209

210210
// Act
211211
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -231,7 +231,7 @@ public void GetAllInstances_RegistrationPrependedToExistingOpenGenericRegistrati
231231

232232
var registration = Lifestyle.Transient.CreateRegistration<StructEventHandler>(container);
233233

234-
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
234+
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
235235

236236
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(NewConstraintEventHandler<>) });
237237

@@ -258,9 +258,9 @@ public void GetAllInstances_MultipleAppendedOpenGenericTypes_ResolvesTheExpected
258258

259259
var container = ContainerFactory.New();
260260

261-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
262-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
263-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
261+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
262+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
263+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
264264

265265
// Act
266266
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -285,14 +285,14 @@ public void GetAllInstances_MultipleAppendedOpenGenericTypesMixedWithClosedGener
285285

286286
var container = ContainerFactory.New();
287287

288-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
288+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
289289

290290
container.RegisterCollection(typeof(IEventHandler<StructEvent>), new[]
291291
{
292292
typeof(AuditableEventEventHandler<StructEvent>)
293293
});
294294

295-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
295+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
296296

297297
// Act
298298
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -319,8 +319,8 @@ public void GetAllInstances_MultipleOpenGenericTypesAppendedToPreRegistrationWit
319319

320320
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(NewConstraintEventHandler<>) });
321321

322-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
323-
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
322+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
323+
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
324324

325325
// Act
326326
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -348,7 +348,7 @@ public void GetAllInstances_RegistrationAppendedToExistingRegistrationForSameClo
348348
var registration = Lifestyle.Singleton
349349
.CreateRegistration(typeof(StructConstraintEventHandler<StructEvent>), container);
350350

351-
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
351+
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
352352

353353
// Act
354354
var handler1 = container.GetAllInstances<IEventHandler<StructEvent>>().Last();
@@ -375,7 +375,7 @@ public void GetAllInstances_DelegatedRegistrationAppendedToExistingRegistrationF
375375
() => new StructConstraintEventHandler<StructEvent>(),
376376
container);
377377

378-
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
378+
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
379379

380380
// Act
381381
var handler1 = container.GetAllInstances<IEventHandler<StructEvent>>().Last();

src/SimpleInjector.Tests.Unit/ContainerCollectionsCreateRegistrationTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public void CreateRegistration_CalledTwiceForSameCollectionType_ReturnsSeparateI
1717
var container = new Container();
1818

1919
// Act
20-
var reg1 = container.Collections.CreateRegistration<ILogger>(typeof(NullLogger));
21-
var reg2 = container.Collections.CreateRegistration<ILogger>(typeof(ConsoleLogger));
20+
var reg1 = container.Collection.CreateRegistration<ILogger>(typeof(NullLogger));
21+
var reg2 = container.Collection.CreateRegistration<ILogger>(typeof(ConsoleLogger));
2222

2323
// Assert
2424
Assert.AreNotSame(reg1, reg2,
@@ -34,8 +34,8 @@ public void CreateRegistration_CalledTwiceForSameCollectionType_ProducesStreamsT
3434
var container = new Container();
3535

3636
// Act
37-
var reg1 = container.Collections.CreateRegistration<ILogger>(typeof(NullLogger));
38-
var reg2 = container.Collections.CreateRegistration<ILogger>(typeof(ConsoleLogger));
37+
var reg1 = container.Collection.CreateRegistration<ILogger>(typeof(NullLogger));
38+
var reg2 = container.Collection.CreateRegistration<ILogger>(typeof(ConsoleLogger));
3939

4040
var prod1 = new InstanceProducer<IEnumerable<ILogger>>(reg1);
4141
var prod2 = new InstanceProducer<IEnumerable<ILogger>>(reg2);
@@ -57,7 +57,7 @@ public void Verify_WhenRegistrationIsCreatedForTypeThatFailsDuringCreation_Verif
5757
// Arrange
5858
var container = new Container();
5959

60-
var registration = container.Collections.CreateRegistration<ILogger>(typeof(FailingConstructorLogger));
60+
var registration = container.Collection.CreateRegistration<ILogger>(typeof(FailingConstructorLogger));
6161

6262
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
6363
// to ensure that to memory is leaked, but as long as stream is referenced, should it as well be
@@ -78,7 +78,7 @@ public void Verify_WhenRegistrationIsCreatedForTypeThatFailsDuringCreation_Verif
7878
private static IEnumerable<T> GetStreamFromRegistration<T>(
7979
Container container, params Type[] serviceTypes) where T : class
8080
{
81-
var reg = container.Collections.CreateRegistration<T>(serviceTypes);
81+
var reg = container.Collection.CreateRegistration<T>(serviceTypes);
8282
var prod = new InstanceProducer<IEnumerable<T>>(reg);
8383
return prod.GetInstance();
8484
}

src/SimpleInjector.Tests.Unit/ContainerCollectionsCreateTests.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public void Create_WhenReturnedCollectionIterated_ProducesTheExpectedInstances()
1717
var container = new Container();
1818

1919
// Act
20-
var stream = container.Collections.Create<ILogger>(expectedTypes);
20+
var stream = container.Collection.Create<ILogger>(expectedTypes);
2121

2222
// Assert
2323
AssertThat.SequenceEquals(expectedTypes, actualTypes: stream.Select(GetType));
@@ -33,8 +33,8 @@ public void Create_CreatingMultipleCollectionsOfTheSameServiceType_ProducesTheEx
3333
var container = new Container();
3434

3535
// Act
36-
var stream1 = container.Collections.Create<ILogger>(expectedTypes1);
37-
var stream2 = container.Collections.Create<ILogger>(expectedTypes2);
36+
var stream1 = container.Collection.Create<ILogger>(expectedTypes1);
37+
var stream2 = container.Collection.Create<ILogger>(expectedTypes2);
3838

3939
// Assert
4040
AssertThat.SequenceEquals(expectedTypes1, actualTypes: stream1.Select(GetType));
@@ -50,7 +50,7 @@ public void Create_CollectionWithAbstraction_CallsBackIntoContainerUponIteration
5050
container.Register<ILogger, ConsoleLogger>();
5151

5252
// Act
53-
var stream = container.Collections.Create<ILogger>(typeof(ILogger));
53+
var stream = container.Collection.Create<ILogger>(typeof(ILogger));
5454

5555
// Assert
5656
AssertThat.SequenceEquals(
@@ -64,7 +64,7 @@ public void Create_IteratingACreatedCollection_LocksTheContainer()
6464
// Arrange
6565
var container = new Container();
6666

67-
var stream = container.Collections.Create<ILogger>(typeof(ConsoleLogger));
67+
var stream = container.Collection.Create<ILogger>(typeof(ConsoleLogger));
6868

6969
stream.First();
7070

@@ -87,7 +87,7 @@ public void Create_WhenIterated_PreservesLifestyles()
8787
container.Register<NullLogger>(Lifestyle.Singleton);
8888

8989
// Act
90-
var stream = container.Collections.Create<ILogger>(typeof(ConsoleLogger), typeof(NullLogger));
90+
var stream = container.Collection.Create<ILogger>(typeof(ConsoleLogger), typeof(NullLogger));
9191

9292
// Assert
9393
Assert.AreNotSame(stream.First(), stream.First(), "ConsoleLogger was expected to be transient.");
@@ -101,7 +101,7 @@ public void Create_WithSetOfRegistrations_ProducesTheExpectedInstancesUponIterat
101101
var container = new Container();
102102

103103
// Act
104-
var stream = container.Collections.Create<ILogger>(
104+
var stream = container.Collection.Create<ILogger>(
105105
Lifestyle.Singleton.CreateRegistration<ConsoleLogger>(container),
106106
Lifestyle.Transient.CreateRegistration<NullLogger>(container));
107107

@@ -124,8 +124,8 @@ public void Create_MultipleStreamsUsingTheSameSingletonComponent_PreservesLifest
124124
container.Register<NullLogger>(Lifestyle.Singleton);
125125

126126
// Act
127-
var stream1 = container.Collections.Create<ILogger>(expectedTypes1);
128-
var stream2 = container.Collections.Create<ILogger>(expectedTypes2);
127+
var stream1 = container.Collection.Create<ILogger>(expectedTypes1);
128+
var stream2 = container.Collection.Create<ILogger>(expectedTypes2);
129129

130130
var nullLoggerFromStream1 = stream1.OfType<NullLogger>().Single();
131131
var nullLoggerFromStream2 = stream2.OfType<NullLogger>().Single();
@@ -140,7 +140,7 @@ public void Verify_WhenCollectionIsCreatedForTypeThatFailsDuringCreation_VerifyT
140140
// Arrange
141141
var container = new Container();
142142

143-
var stream = container.Collections.Create<ILogger>(typeof(FailingConstructorLogger));
143+
var stream = container.Collection.Create<ILogger>(typeof(FailingConstructorLogger));
144144

145145
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
146146
// to ensure that to memory is leaked, but as long as stream is referenced, should it as well be
@@ -164,7 +164,7 @@ public void Verify_WhenCollectionIsCreatedForRegistrationThatFailsDuringCreation
164164
// Arrange
165165
var container = new Container();
166166

167-
var stream = container.Collections.Create<ILogger>(
167+
var stream = container.Collection.Create<ILogger>(
168168
Lifestyle.Transient.CreateRegistration<FailingConstructorLogger>(container));
169169

170170
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
@@ -189,7 +189,7 @@ public void Verify_WhenCollectionIsCreatedForTypeThatFailsDuringCreation_VerifyS
189189
// Arrange
190190
var container = new Container();
191191

192-
var stream = container.Collections.Create<ILogger>(typeof(FailingConstructorLogger));
192+
var stream = container.Collection.Create<ILogger>(typeof(FailingConstructorLogger));
193193

194194
// Explicitly clear the reference to stream, so ensure GC.Collect cleans it up (only needed when
195195
// running in debug).
@@ -213,7 +213,7 @@ public void Create_SuppliedWithNullTypeArray_ThrowsArgumentNullException()
213213
var container = new Container();
214214

215215
// Act
216-
Action action = () => container.Collections.Create<ILogger>((Type[])null);
216+
Action action = () => container.Collection.Create<ILogger>((Type[])null);
217217

218218
// Assert
219219
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceTypes", action);
@@ -226,7 +226,7 @@ public void Create_SuppliedWithNullEnumerable_ThrowsArgumentNullException()
226226
var container = new Container();
227227

228228
// Act
229-
Action action = () => container.Collections.Create<ILogger>((IEnumerable<Type>)null);
229+
Action action = () => container.Collection.Create<ILogger>((IEnumerable<Type>)null);
230230

231231
// Assert
232232
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceTypes", action);
@@ -241,7 +241,7 @@ public void Create_SuppliedWithNullElement_ThrowsException()
241241
var container = new Container();
242242

243243
// Act
244-
Action action = () => container.Collections.Create<ILogger>(expectedTypes);
244+
Action action = () => container.Collection.Create<ILogger>(expectedTypes);
245245

246246
// Assert
247247
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
@@ -258,7 +258,7 @@ public void Create_SuppliedWithIncompatibleType_ThrowsException()
258258
var container = new Container();
259259

260260
// Act
261-
Action action = () => container.Collections.Create<ILogger>(listWithIncompatibleType);
261+
Action action = () => container.Collection.Create<ILogger>(listWithIncompatibleType);
262262

263263
// Assert
264264
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
@@ -275,7 +275,7 @@ public void Create_SuppliedWithOpenGenericType_ThrowsException()
275275
var container = new Container();
276276

277277
// Act
278-
Action action = () => container.Collections.Create<ILogger>(new[] { invalidType });
278+
Action action = () => container.Collection.Create<ILogger>(new[] { invalidType });
279279

280280
// Assert
281281
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(

src/SimpleInjector.Tests.Unit/ContainerOptionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void AllowOverridingRegistrations_SetToTrue_ContainerReplacesAppendedRegi
207207

208208
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(AuditableEventEventHandlerWithUnknown<int>) });
209209

210-
container.Collections.AppendTo(typeof(IEventHandler<AuditableEvent>), typeof(NewConstraintEventHandler<AuditableEvent>));
210+
container.Collection.AppendTo(typeof(IEventHandler<AuditableEvent>), typeof(NewConstraintEventHandler<AuditableEvent>));
211211

212212
// Act
213213
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(AuditableEventEventHandler) });

0 commit comments

Comments
 (0)