Permalink
Browse files

Renamed Container.Collections to Container.Collection. Related to #556.

  • Loading branch information...
dotnetjunkie committed May 15, 2018
1 parent 44bc800 commit 3f3ee08dc5fbc8de3248b42a8ef943090b6d9294
@@ -15,7 +15,7 @@ public void AppendTo_WithValidArguments_Suceeds()
var container = ContainerFactory.New();
// Act
container.Collections.AppendTo(typeof(object), CreateRegistration(container));
container.Collection.AppendTo(typeof(object), CreateRegistration(container));
}
[TestMethod]
@@ -28,7 +28,7 @@ public void AppendTo_WithNullServiceTypeArgument_ThrowsException()
// Act
Action action =
() => container.Collections.AppendTo(invalidServiceType, CreateRegistration(container));
() => container.Collection.AppendTo(invalidServiceType, CreateRegistration(container));
// Assert
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceType", action);
@@ -43,7 +43,7 @@ public void AppendTo_WithNullRegistrationArgument_ThrowsException()
Registration invalidRegistration = null;
// Act
Action action = () => container.Collections.AppendTo(typeof(object), invalidRegistration);
Action action = () => container.Collection.AppendTo(typeof(object), invalidRegistration);
// Assert
AssertThat.ThrowsWithParamName<ArgumentNullException>("registration", action);
@@ -60,7 +60,7 @@ public void AppendTo_WithRegistrationForDifferentContainer_ThrowsException()
Registration invalidRegistration = CreateRegistration(differentContainer);
// Act
Action action = () => container.Collections.AppendTo(typeof(object), invalidRegistration);
Action action = () => container.Collection.AppendTo(typeof(object), invalidRegistration);
// Assert
AssertThat.ThrowsWithParamName<ArgumentException>("registration", action);
@@ -76,7 +76,7 @@ public void AppendTo_ForUnregisteredCollection_ResolvesThatRegistrationWhenReque
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
container.Collections.AppendTo(typeof(IPlugin), registration);
container.Collection.AppendTo(typeof(IPlugin), registration);
// Act
var instance = container.GetAllInstances<IPlugin>().Single();
@@ -94,8 +94,8 @@ public void AppendTo_CalledTwice_ResolvesBothRegistrationsWhenRequested()
var registration1 = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
var registration2 = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
container.Collections.AppendTo(typeof(IPlugin), registration1);
container.Collections.AppendTo(typeof(IPlugin), registration2);
container.Collection.AppendTo(typeof(IPlugin), registration1);
container.Collection.AppendTo(typeof(IPlugin), registration2);
// Act
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -115,7 +115,7 @@ public void AppendTo_CalledAfterRegisterCollectionWithTypes_CombinedAllRegistrat
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
container.Collections.AppendTo(typeof(IPlugin), registration);
container.Collection.AppendTo(typeof(IPlugin), registration);
// Act
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -136,7 +136,7 @@ public void AppendTo_CalledAfterRegisterCollectionWithRegistration_CombinedAllRe
container.RegisterCollection(typeof(IPlugin), new[] { registration1 });
container.Collections.AppendTo(typeof(IPlugin), registration2);
container.Collection.AppendTo(typeof(IPlugin), registration2);
// Act
var instances = container.GetAllInstances<IPlugin>().ToArray();
@@ -155,12 +155,12 @@ public void AppendTo_CalledAfterTheFirstItemIsRequested_ThrowsExpectedException(
var registration1 = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
var registration2 = Lifestyle.Transient.CreateRegistration<PluginImpl2>(container);
container.Collections.AppendTo(typeof(IPlugin), registration1);
container.Collection.AppendTo(typeof(IPlugin), registration1);
var instances = container.GetAllInstances<IPlugin>().ToArray();
// Act
Action action = () => container.Collections.AppendTo(typeof(IPlugin), registration2);
Action action = () => container.Collection.AppendTo(typeof(IPlugin), registration2);
// Assert
AssertThat.Throws<InvalidOperationException>(action);
@@ -179,7 +179,7 @@ public void AppendTo_OnContainerUncontrolledCollection_ThrowsExpressiveException
var registration = Lifestyle.Transient.CreateRegistration<PluginImpl>(container);
// Act
Action action = () => container.Collections.AppendTo(typeof(IPlugin), registration);
Action action = () => container.Collection.AppendTo(typeof(IPlugin), registration);
// Assert
AssertThat.ThrowsWithExceptionMessageContains<NotSupportedException>(@"
@@ -205,7 +205,7 @@ public void GetAllInstances_RegistrationAppendedToExistingOpenGenericRegistratio
var registration = Lifestyle.Transient.CreateRegistration<StructEventHandler>(container);
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
// Act
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -231,7 +231,7 @@ public void GetAllInstances_RegistrationPrependedToExistingOpenGenericRegistrati
var registration = Lifestyle.Transient.CreateRegistration<StructEventHandler>(container);
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(NewConstraintEventHandler<>) });
@@ -258,9 +258,9 @@ public void GetAllInstances_MultipleAppendedOpenGenericTypes_ResolvesTheExpected
var container = ContainerFactory.New();
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
// Act
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -285,14 +285,14 @@ public void GetAllInstances_MultipleAppendedOpenGenericTypesMixedWithClosedGener
var container = ContainerFactory.New();
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(NewConstraintEventHandler<>));
container.RegisterCollection(typeof(IEventHandler<StructEvent>), new[]
{
typeof(AuditableEventEventHandler<StructEvent>)
});
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
// Act
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -319,8 +319,8 @@ public void GetAllInstances_MultipleOpenGenericTypesAppendedToPreRegistrationWit
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(NewConstraintEventHandler<>) });
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
container.Collections.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(StructConstraintEventHandler<>));
container.Collection.AppendTo(typeof(IEventHandler<>), typeof(AuditableEventEventHandler<>));
// Act
Type[] actualHandlerTypes = container.GetAllInstances(typeof(IEventHandler<StructEvent>))
@@ -348,7 +348,7 @@ public void GetAllInstances_RegistrationAppendedToExistingRegistrationForSameClo
var registration = Lifestyle.Singleton
.CreateRegistration(typeof(StructConstraintEventHandler<StructEvent>), container);
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
// Act
var handler1 = container.GetAllInstances<IEventHandler<StructEvent>>().Last();
@@ -375,7 +375,7 @@ public void GetAllInstances_DelegatedRegistrationAppendedToExistingRegistrationF
() => new StructConstraintEventHandler<StructEvent>(),
container);
container.Collections.AppendTo(typeof(IEventHandler<>), registration);
container.Collection.AppendTo(typeof(IEventHandler<>), registration);
// Act
var handler1 = container.GetAllInstances<IEventHandler<StructEvent>>().Last();
@@ -17,8 +17,8 @@ public void CreateRegistration_CalledTwiceForSameCollectionType_ReturnsSeparateI
var container = new Container();
// Act
var reg1 = container.Collections.CreateRegistration<ILogger>(typeof(NullLogger));
var reg2 = container.Collections.CreateRegistration<ILogger>(typeof(ConsoleLogger));
var reg1 = container.Collection.CreateRegistration<ILogger>(typeof(NullLogger));
var reg2 = container.Collection.CreateRegistration<ILogger>(typeof(ConsoleLogger));
// Assert
Assert.AreNotSame(reg1, reg2,
@@ -34,8 +34,8 @@ public void CreateRegistration_CalledTwiceForSameCollectionType_ProducesStreamsT
var container = new Container();
// Act
var reg1 = container.Collections.CreateRegistration<ILogger>(typeof(NullLogger));
var reg2 = container.Collections.CreateRegistration<ILogger>(typeof(ConsoleLogger));
var reg1 = container.Collection.CreateRegistration<ILogger>(typeof(NullLogger));
var reg2 = container.Collection.CreateRegistration<ILogger>(typeof(ConsoleLogger));
var prod1 = new InstanceProducer<IEnumerable<ILogger>>(reg1);
var prod2 = new InstanceProducer<IEnumerable<ILogger>>(reg2);
@@ -57,7 +57,7 @@ public void Verify_WhenRegistrationIsCreatedForTypeThatFailsDuringCreation_Verif
// Arrange
var container = new Container();
var registration = container.Collections.CreateRegistration<ILogger>(typeof(FailingConstructorLogger));
var registration = container.Collection.CreateRegistration<ILogger>(typeof(FailingConstructorLogger));
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
// 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
private static IEnumerable<T> GetStreamFromRegistration<T>(
Container container, params Type[] serviceTypes) where T : class
{
var reg = container.Collections.CreateRegistration<T>(serviceTypes);
var reg = container.Collection.CreateRegistration<T>(serviceTypes);
var prod = new InstanceProducer<IEnumerable<T>>(reg);
return prod.GetInstance();
}
@@ -17,7 +17,7 @@ public void Create_WhenReturnedCollectionIterated_ProducesTheExpectedInstances()
var container = new Container();
// Act
var stream = container.Collections.Create<ILogger>(expectedTypes);
var stream = container.Collection.Create<ILogger>(expectedTypes);
// Assert
AssertThat.SequenceEquals(expectedTypes, actualTypes: stream.Select(GetType));
@@ -33,8 +33,8 @@ public void Create_CreatingMultipleCollectionsOfTheSameServiceType_ProducesTheEx
var container = new Container();
// Act
var stream1 = container.Collections.Create<ILogger>(expectedTypes1);
var stream2 = container.Collections.Create<ILogger>(expectedTypes2);
var stream1 = container.Collection.Create<ILogger>(expectedTypes1);
var stream2 = container.Collection.Create<ILogger>(expectedTypes2);
// Assert
AssertThat.SequenceEquals(expectedTypes1, actualTypes: stream1.Select(GetType));
@@ -50,7 +50,7 @@ public void Create_CollectionWithAbstraction_CallsBackIntoContainerUponIteration
container.Register<ILogger, ConsoleLogger>();
// Act
var stream = container.Collections.Create<ILogger>(typeof(ILogger));
var stream = container.Collection.Create<ILogger>(typeof(ILogger));
// Assert
AssertThat.SequenceEquals(
@@ -64,7 +64,7 @@ public void Create_IteratingACreatedCollection_LocksTheContainer()
// Arrange
var container = new Container();
var stream = container.Collections.Create<ILogger>(typeof(ConsoleLogger));
var stream = container.Collection.Create<ILogger>(typeof(ConsoleLogger));
stream.First();
@@ -87,7 +87,7 @@ public void Create_WhenIterated_PreservesLifestyles()
container.Register<NullLogger>(Lifestyle.Singleton);
// Act
var stream = container.Collections.Create<ILogger>(typeof(ConsoleLogger), typeof(NullLogger));
var stream = container.Collection.Create<ILogger>(typeof(ConsoleLogger), typeof(NullLogger));
// Assert
Assert.AreNotSame(stream.First(), stream.First(), "ConsoleLogger was expected to be transient.");
@@ -101,7 +101,7 @@ public void Create_WithSetOfRegistrations_ProducesTheExpectedInstancesUponIterat
var container = new Container();
// Act
var stream = container.Collections.Create<ILogger>(
var stream = container.Collection.Create<ILogger>(
Lifestyle.Singleton.CreateRegistration<ConsoleLogger>(container),
Lifestyle.Transient.CreateRegistration<NullLogger>(container));
@@ -124,8 +124,8 @@ public void Create_MultipleStreamsUsingTheSameSingletonComponent_PreservesLifest
container.Register<NullLogger>(Lifestyle.Singleton);
// Act
var stream1 = container.Collections.Create<ILogger>(expectedTypes1);
var stream2 = container.Collections.Create<ILogger>(expectedTypes2);
var stream1 = container.Collection.Create<ILogger>(expectedTypes1);
var stream2 = container.Collection.Create<ILogger>(expectedTypes2);
var nullLoggerFromStream1 = stream1.OfType<NullLogger>().Single();
var nullLoggerFromStream2 = stream2.OfType<NullLogger>().Single();
@@ -140,7 +140,7 @@ public void Verify_WhenCollectionIsCreatedForTypeThatFailsDuringCreation_VerifyT
// Arrange
var container = new Container();
var stream = container.Collections.Create<ILogger>(typeof(FailingConstructorLogger));
var stream = container.Collection.Create<ILogger>(typeof(FailingConstructorLogger));
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
// 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
// Arrange
var container = new Container();
var stream = container.Collections.Create<ILogger>(
var stream = container.Collection.Create<ILogger>(
Lifestyle.Transient.CreateRegistration<FailingConstructorLogger>(container));
// Notice the explicit call to GC.Collect(). Simple Injector holds on to 'stuff' using WeakReferences
@@ -189,7 +189,7 @@ public void Verify_WhenCollectionIsCreatedForTypeThatFailsDuringCreation_VerifyS
// Arrange
var container = new Container();
var stream = container.Collections.Create<ILogger>(typeof(FailingConstructorLogger));
var stream = container.Collection.Create<ILogger>(typeof(FailingConstructorLogger));
// Explicitly clear the reference to stream, so ensure GC.Collect cleans it up (only needed when
// running in debug).
@@ -213,7 +213,7 @@ public void Create_SuppliedWithNullTypeArray_ThrowsArgumentNullException()
var container = new Container();
// Act
Action action = () => container.Collections.Create<ILogger>((Type[])null);
Action action = () => container.Collection.Create<ILogger>((Type[])null);
// Assert
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceTypes", action);
@@ -226,7 +226,7 @@ public void Create_SuppliedWithNullEnumerable_ThrowsArgumentNullException()
var container = new Container();
// Act
Action action = () => container.Collections.Create<ILogger>((IEnumerable<Type>)null);
Action action = () => container.Collection.Create<ILogger>((IEnumerable<Type>)null);
// Assert
AssertThat.ThrowsWithParamName<ArgumentNullException>("serviceTypes", action);
@@ -241,7 +241,7 @@ public void Create_SuppliedWithNullElement_ThrowsException()
var container = new Container();
// Act
Action action = () => container.Collections.Create<ILogger>(expectedTypes);
Action action = () => container.Collection.Create<ILogger>(expectedTypes);
// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
@@ -258,7 +258,7 @@ public void Create_SuppliedWithIncompatibleType_ThrowsException()
var container = new Container();
// Act
Action action = () => container.Collections.Create<ILogger>(listWithIncompatibleType);
Action action = () => container.Collection.Create<ILogger>(listWithIncompatibleType);
// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
@@ -275,7 +275,7 @@ public void Create_SuppliedWithOpenGenericType_ThrowsException()
var container = new Container();
// Act
Action action = () => container.Collections.Create<ILogger>(new[] { invalidType });
Action action = () => container.Collection.Create<ILogger>(new[] { invalidType });
// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
@@ -207,7 +207,7 @@ public void AllowOverridingRegistrations_SetToTrue_ContainerReplacesAppendedRegi
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(AuditableEventEventHandlerWithUnknown<int>) });
container.Collections.AppendTo(typeof(IEventHandler<AuditableEvent>), typeof(NewConstraintEventHandler<AuditableEvent>));
container.Collection.AppendTo(typeof(IEventHandler<AuditableEvent>), typeof(NewConstraintEventHandler<AuditableEvent>));
// Act
container.RegisterCollection(typeof(IEventHandler<>), new[] { typeof(AuditableEventEventHandler) });
Oops, something went wrong.

0 comments on commit 3f3ee08

Please sign in to comment.