Permalink
Browse files

Merge branch 'v4.4.x' of https://github.com/simpleinjector/SimpleInje…

  • Loading branch information...
dotnetjunkie committed Jan 1, 2019
2 parents 29fb632 + 56c55d8 commit 9481f988b552cde59a0109ac62be7170345b8676
@@ -65,7 +65,7 @@ public void AddRegistration_SuppliedWithOpenGenericServiceType_ThrowsExpectedExc

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type ICommandHandler<TCommand> is an open generic type.",
"The supplied type ICommandHandler<TCommand> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("serviceType", action);
}
@@ -85,7 +85,7 @@ public void AddRegistration_SuppliedWithPartialOpenGenericServiceType_ThrowsExpe

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type ICommandHandler<List<T>> is an open generic type.",
"The supplied type ICommandHandler<List<T>> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("serviceType", action);
}
@@ -287,7 +287,7 @@ public void Create_SuppliedWithOpenGenericType_ThrowsException()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type Logger<T> is an open generic type.",
"The supplied type Logger<T> is an open-generic type.",
action);
}

@@ -129,7 +129,7 @@ public void RegisterDecorator_RegisteringAnOpenGenericDecoratorWithANonGenericSe

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied decorator NonGenericServiceDecorator<T> is an open generic type definition",
"The supplied decorator NonGenericServiceDecorator<T> is an open-generic type definition",
action);

AssertThat.ThrowsWithParamName("decoratorType", action);
@@ -196,9 +196,8 @@ public void RegisterDecorator_WithClosedGenericServiceAndOpenGenericDecorator_Fa
{
// Arrange
string expectedMessage = @"
Registering a closed generic service type with an open generic decorator is not supported.
Instead, register the service type as open generic, and the decorator as closed generic
type."
Registering a closed-generic service type with an open-generic decorator is not supported.
Instead, register the service type as open generic, and the decorator type as closed generic."
.TrimInside();

var container = ContainerFactory.New();
@@ -2093,9 +2092,9 @@ public void GetInstance_RegisterDecoratorWithFactoryReturningTypeWithMultiplePub
public void GetInstance_RegisterDecoratorWithNonGenericServiceAndFactoryReturningAnOpenGenericDecoratorType_ThrowsExpectedException()
{
// Arrange
string expectedMessage = @"The registered decorator type factory returned open generic type
string expectedMessage = @"The registered decorator type factory returned open-generic type
NonGenericServiceDecorator<T> while the registered service type INonGenericService is not
generic, making it impossible for a closed generic decorator type to be constructed"
generic, making it impossible for a closed-generic decorator type to be constructed"
.TrimInside();

var container = new Container();
@@ -2443,7 +2442,7 @@ public void RegisterDecorator_WithPartialOpenGenericServiceType_ThrowsExpectedMe

AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The supplied type 'ICommandHandler<List<T>>' is a partially-closed generic type, which is not
supported by this method. Please supply the open generic type 'ICommandHandler<>' instead."
supported by this method. Please supply the open-generic type 'ICommandHandler<>' instead."
.TrimInside(),
action);
}
@@ -2468,7 +2467,7 @@ public void RegisterDecorator_WithConstructedGenericServiceType_ThrowsExpectedMe

AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The supplied type 'ICommandHandler<TCommand>' is a partially-closed generic type, which is not
supported by this method. Please supply the open generic type 'ICommandHandler<>' instead."
supported by this method. Please supply the open-generic type 'ICommandHandler<>' instead."
.TrimInside(),
action);
}
@@ -131,8 +131,8 @@ public void GetInstance_WithOpenGenericType_ThrowsExpectedException()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The request for type Lazy<T> is invalid because it is an open generic type: it is only
possible to instantiate instances of closed generic types. A generic type is closed if all of
The request for type Lazy<T> is invalid because it is an open-generic type: it is only
possible to instantiate instances of closed-generic types. A generic type is closed if all of
its type parameters have been substituted with types that are recognized by the compiler."
.TrimInside(),
action);
@@ -339,7 +339,7 @@ public void GetRegistration_OnOpenGenericType_ThrowsExpectedException()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"IEnumerable<T> is invalid because it is an open generic type",
"IEnumerable<T> is invalid because it is an open-generic type",
action);
}

@@ -186,7 +186,7 @@ public void CreateProducer_SuppliedWithOpenGenericServiceType_ThrowsExpectedExce

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type ICommandHandler<TCommand> is an open generic type.",
"The supplied type ICommandHandler<TCommand> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("serviceType", action);
}
@@ -204,7 +204,7 @@ public void CreateProducer_SuppliedWithOpenGenericImplementationType_ThrowsExpec

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type NullCommandHandler<T> is an open generic type.",
"The supplied type NullCommandHandler<T> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("implementationType", action);
}
@@ -221,7 +221,7 @@ public void CreateProducerTService_SuppliedWithOpenGenericImplementationType_Thr

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type NullCommandHandler<T> is an open generic type.",
"The supplied type NullCommandHandler<T> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("implementationType", action);
}
@@ -238,7 +238,7 @@ public void CreateRegistrationTConcrete_SuppliedWithOpenGenericConcreteType_Thro

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type NullCommandHandler<T> is an open generic type.",
"The supplied type NullCommandHandler<T> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("concreteType", action);
}
@@ -271,7 +271,7 @@ public void CreateRegistration_SuppliedWithOpenGenericImplementationType_ThrowsE

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type NullCommandHandler<T> is an open generic type.",
"The supplied type NullCommandHandler<T> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("concreteType", action);
}
@@ -288,7 +288,7 @@ public void CreateRegistrationFunc_SuppliedWithOpenGenericServiceType_ThrowsExpe

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"The supplied type ICommandHandler<TCommand> is an open generic type.",
"The supplied type ICommandHandler<TCommand> is an open-generic type.",
action);
AssertThat.ThrowsWithParamName("serviceType", action);
}
@@ -162,7 +162,7 @@ public void GetInstance_WithoutAsyncScopedLifestyle_ThrowsExpectedException()
catch (ActivationException ex)
{
AssertThat.ExceptionMessageContains(@"
The ConcreteCommand is registered as 'Async Scoped' lifestyle, but the instance is
ConcreteCommand is registered as 'Async Scoped' lifestyle, but the instance is
requested outside the context of an active (Async Scoped) scope."
.TrimInside(),
ex);
@@ -141,7 +141,7 @@ public void GetInstance_WithoutLifetimeScope_ThrowsExpectedException()
catch (ActivationException ex)
{
AssertThat.ExceptionMessageContains(@"
The ConcreteCommand is registered as 'Thread Scoped' lifestyle, but the instance is
ConcreteCommand is registered as 'Thread Scoped' lifestyle, but the instance is
requested outside the context of an active (Thread Scoped) scope."
.TrimInside(),
ex);
@@ -45,7 +45,7 @@ public void RegisterAssemblies_WithNonGenericType_Fails()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The supplied type ILogger is not a generic type. This method only supports open generic types.
The supplied type ILogger is not a generic type. This method only supports open-generic types.
If you meant to register all available implementations of ILogger, call
Container.Collection.Register(typeof(ILogger), IEnumerable<Assembly>) instead.".TrimInside(),
action);
@@ -62,7 +62,7 @@ public void RegisterAssemblies_WithClosedGenericType_Fails()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(string.Format(@"
The supplied type {0} is not an open generic type. Supply this method with the open generic
The supplied type {0} is not an open-generic type. Supply this method with the open-generic
type {1} to register all available implementations of this type, or call
Container.Collection.Register(Type, IEnumerable<Assembly>) either with the open or closed version of
that type to register a collection of instances based on that type.".TrimInside(),
@@ -82,7 +82,7 @@ public void RegisterTypes_WithNonGenericType_Fails()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The supplied type ILogger is not a generic type. This method only supports open generic types.
The supplied type ILogger is not a generic type. This method only supports open-generic types.
If you meant to register all available implementations of ILogger, call
Container.Collection.Register(typeof(ILogger), IEnumerable<Type>) instead.".TrimInside(),
action);
@@ -99,7 +99,7 @@ public void RegisterTypes_WithClosedGenericType_Fails()

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(string.Format(@"
The supplied type {0} is not an open generic type. Supply this method with the open generic
The supplied type {0} is not an open-generic type. Supply this method with the open-generic
type {1} to register all available implementations of this type, or call
Container.Collection.Register(Type, IEnumerable<Type>) either with the open or closed version of
that type to register a collection of instances based on that type.".TrimInside(),
@@ -258,7 +258,7 @@ public void Register_WithMultipleTypeDefinitionsReferencingTheSameInterface_Fail
// Assert
AssertThat.ThrowsWithExceptionMessageContains<InvalidOperationException>(
"In the supplied list of types or assemblies, there are 2 types that represent the same " +
"closed generic type",
"closed-generic type",
action);
}

@@ -424,8 +424,8 @@ public void RegisterTypes_SuppliedWithOpenGenericType_FailsWithExpectedException
// Assert
AssertThat.ThrowsWithParamName("implementationTypes", action);
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(@"
The supplied list of types contains one or multiple open generic types, but this method
is unable to handle open generic types because it can only map closed generic service
The supplied list of types contains one or multiple open-generic types, but this method
is unable to handle open-generic types because it can only map closed-generic service
types to a single implementation. You must register the open-generic types separately
using the Register(Type, Type) overload."
.TrimInside(),
@@ -294,7 +294,7 @@ public void RegisterCollection_ForAnOpenGenericCollectionAfterACallOfAClosedGene

// Assert
AssertThat.ThrowsWithExceptionMessageContains<InvalidOperationException>(@"
Mixing calls to Container.Collection.Register for the same open generic service type is not supported. Consider
Mixing calls to Container.Collection.Register for the same open-generic service type is not supported. Consider
making one single call to Container.Collection.Register(typeof(IEventHandler<>), types)."
.TrimInside(),
action);
@@ -316,7 +316,7 @@ public void RegisterCollection_ForClosedGenericCollectionAfterACallOfThatOpenGen

// Assert
AssertThat.ThrowsWithExceptionMessageContains<InvalidOperationException>(@"
Mixing calls to Container.Collection.Register for the same open generic service type is not supported. Consider
Mixing calls to Container.Collection.Register for the same open-generic service type is not supported. Consider
making one single call to Container.Collection.Register(typeof(IEventHandler<>), types)."
.TrimInside(),
action);
@@ -9,7 +9,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SimpleInjector;
using SimpleInjector.Advanced;
using SimpleInjector.Internals;

/// <summary>Tests for RegisterCollection.</summary>
[TestClass]
@@ -961,7 +960,7 @@ public void RegisterCollection_WithOpenGenericType_FailsWithExpectedExceptionMes
}
catch (ArgumentException ex)
{
Assert.IsTrue(ex.Message.Contains("open generic type"), "Actual: " + ex.Message);
Assert.IsTrue(ex.Message.Contains("open-generic type"), "Actual: " + ex.Message);
}
}

@@ -710,8 +710,8 @@ public void GetInstance_GenericConditionalRegistrationThatOverlapsWithClosedRegi
// Assert
AssertThat.ThrowsWithExceptionMessageContains<ActivationException>(@"
Multiple applicable registrations found for IGeneric<Int32>. The applicable registrations are
(1) the unconditional closed generic registration for IGeneric<Int32> using IntGenericType and
(2) the conditional open generic registration for IGeneric<T> using GenericType<T>.
(1) the unconditional closed-generic registration for IGeneric<Int32> using IntGenericType and
(2) the conditional open-generic registration for IGeneric<T> using GenericType<T>.
If your goal is to make one registration a fallback in case another registration is not
applicable, make the fallback registration last using RegisterConditional and make sure
the supplied predicate returns false in case the Handled property is true."
@@ -1190,9 +1190,9 @@ public void GetInstance_RegisterTypeWithNonGenericServiceAndFactoryReturningAnOp

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ActivationException>(
@"The registered type factory returned open generic type DisposableOpenGenericWithPredicate<T>
@"The registered type factory returned open-generic type DisposableOpenGenericWithPredicate<T>
while the registered service type IDisposable is not generic, making it impossible for a
closed generic type to be constructed"
closed-generic type to be constructed"
.TrimInside(),
action);
}
@@ -1313,7 +1313,7 @@ public void ConditionalRegistration_SupplyingOpenGenericServiceType_ThrowsExpect

// Assert
AssertThat.ThrowsWithExceptionMessageContains<ArgumentException>(
"IGeneric<T> is an open generic type",
"IGeneric<T> is an open-generic type",
action);
}

Oops, something went wrong.

0 comments on commit 9481f98

Please sign in to comment.