public void BuildExpression_WithNullParameterArgument_ThrowsExpectedException() { // Arrange var behavior = GetContainerOptions().DependencyInjectionBehavior; // Act Action action = () => behavior.GetInstanceProducer(null, false); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("consumer", action); }
public void RegisterAllOpenGeneric_WithNullContainerParameter_ThrowsArgumentNullException() { // Arrange Container invalidContainer = null; // Act Action action = () => invalidContainer.RegisterAllOpenGeneric(typeof(int), typeof(int)); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("container", action); }
public void RegisterAllOpenGeneric_WithNullOpenGenericServiceTypeParameter_ThrowsArgumentNullException() { // Arrange Type invalidOpenGenericServiceType = null; // Act Action action = () => (new Container()).RegisterAllOpenGeneric(invalidOpenGenericServiceType, typeof(int)); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("openGenericServiceType", action); }
public void AppendToCollection_WithNullContainerArgument_ThrowsException() { // Arrange Container invalidContainer = null; // Act Action action = () => invalidContainer.AppendToCollection(typeof(object), CreateRegistration(new Container())); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("container", action); }
public void RegisterAllOpenGeneric_WithNullLifestyleParameter_ThrowsArgumentNullException() { // Arrange Lifestyle invalidLifestyle = null; // Act Action action = () => (new Container()).RegisterAllOpenGeneric(typeof(int), invalidLifestyle, typeof(int)); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("lifestyle", action); }
public void RegisterAllOpenGeneric_WithNullOpenGenericImplementationsParameter_ThrowsArgumentNullException() { // Arrange IEnumerable <Type> invalidOpenGenericImplementations = null; // Act Action action = () => (new Container()).RegisterAllOpenGeneric(typeof(int), invalidOpenGenericImplementations); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("openGenericImplementations", action); }
public void Ctor_WithNullChildRegistration_ThrowsExpectedException() { // Arrange var invalidParameters = ValidKnownRelationshipParameters(); invalidParameters.Dependency = null; // Act Action action = () => CreateKnownRelationship(invalidParameters); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("dependency", action); }
public void Ctor_WithNullParentLifestyle_ThrowsExpectedException() { // Arrange var invalidParameters = ValidKnownRelationshipParameters(); invalidParameters.Lifestyle = null; // Act Action action = () => CreateKnownRelationship(invalidParameters); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("lifestyle", action); }
public void AppendToCollection_WithNullRegistrationArgument_ThrowsException() { // Arrange var container = ContainerFactory.New(); Registration invalidRegistration = null; // Act Action action = () => container.AppendToCollection(typeof(object), invalidRegistration); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("registration", action); }
public void RegisterAllOpenGeneric_WithEmptyOpenGenericImplementationsParameter_ThrowsArgumentException() { // Arrange IEnumerable <Type> invalidOpenGenericImplementations = Enumerable.Empty <Type>(); // Act Action action = () => (new Container()).RegisterAllOpenGeneric(typeof(int), invalidOpenGenericImplementations); // Assert AssertThat.ThrowsWithParamName <ArgumentException>("openGenericImplementations", action); AssertThat.ThrowsWithExceptionMessageContains <ArgumentException>( "The supplied collection should contain at least one element.", action); }
public void AppendToCollection_WithNullServiceTypeArgument_ThrowsException() { // Arrange var container = ContainerFactory.New(); Type invalidServiceType = null; // Act Action action = () => container.AppendToCollection(invalidServiceType, CreateRegistration(container)); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("serviceType", action); }
public void WhenCurrentRequestEnds_WithNullContainer_ThrowsExpectedException() { // Arrange Container invalidContainer = null; using (new HttpContextScope()) { // Act Action action = () => WebRequestLifestyle.WhenCurrentRequestEnds(invalidContainer, () => { }); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("container", action); } }
public void WhenCurrentRequestEnds_WithNullAction_ThrowsExpectedException() { // Arrange Action invalidAction = null; using (new HttpContextScope()) { // Act Action action = () => WebRequestLifestyle.WhenCurrentRequestEnds(new Container(), invalidAction); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("action", action); } }
public void RegisterAllOpenGeneric_WitEmptyOpenGenericImplementationsWithNullValues_ThrowsArgumentException() { // Arrange IEnumerable <Type> invalidOpenGenericImplementations = new Type[] { null }; // Act Action action = () => (new Container()).RegisterAllOpenGeneric(typeof(IEventHandler <>), invalidOpenGenericImplementations); // Assert AssertThat.ThrowsWithParamName <ArgumentException>("openGenericImplementations", action); AssertThat.ThrowsWithExceptionMessageContains <ArgumentException>( "The collection contains null elements.", action); }
public void RegisterForDisposal_WithNullContainer_ThrowsExpectedException() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); Container invalidContainer = null; using (new HttpContextScope()) { // Act Action action = () => lifestyle.RegisterForDisposal(invalidContainer, new DisposableCommand()); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("container", action); } }
public void RegisterForDisposal_WithNullAction_ThrowsExpectedException() { // Arrange ScopedLifestyle lifestyle = new WebRequestLifestyle(); IDisposable invalidInstance = null; using (new HttpContextScope()) { // Act Action action = () => lifestyle.RegisterForDisposal(new Container(), invalidInstance); // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("disposable", action); } }
public void AppendToCollection_WithRegistrationForDifferentContainer_ThrowsException() { // Arrange var container = ContainerFactory.New(); var differentContainer = new Container(); Registration invalidRegistration = CreateRegistration(differentContainer); // Act Action action = () => container.AppendToCollection(typeof(object), invalidRegistration); // Assert AssertThat.ThrowsWithParamName <ArgumentException>("registration", action); AssertThat.ThrowsWithExceptionMessageContains <ArgumentException>( "The supplied Registration belongs to a different container.", action); }
public void CreateHybrid_WithNullFalseLifestyle_ReturnsScopedLifestyle() { // Arrange ScopedLifestyle invalidFalseLifestyle = null; // Act Action action = () => { ScopedLifestyle hybrid = Lifestyle.CreateHybrid( () => true, new CustomScopedLifestyle(), invalidFalseLifestyle); }; // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("falseLifestyle", action); }
public void CreateHybrid_WithNullLifestyleSelector_ReturnsScopedLifestyle() { // Arrange Func <bool> invalidLifestyleSelector = null; // Act Action action = () => { ScopedLifestyle hybrid = Lifestyle.CreateHybrid( invalidLifestyleSelector, new CustomScopedLifestyle(), new CustomScopedLifestyle()); }; // Assert AssertThat.ThrowsWithParamName <ArgumentNullException>("lifestyleSelector", action); }
public void RegisterManyForOpenGenericWithoutCallback1_SuppliedWithOpenGenericType_FailsWithExpectedException() { // Arrange var container = ContainerFactory.New(); Type[] types = new[] { typeof(GenericHandler <>) }; // Act Action action = () => container.RegisterManyForOpenGeneric(typeof(ICommandHandler <>), types); // Assert AssertThat.ThrowsWithParamName("typesToRegister", action); AssertThat.ThrowsWithExceptionMessageContains <ArgumentException>(@" The supplied list of types contains an open generic type, but this overloaded method is unable to handle open generic types because this overload can only register closed generic services types that have a single implementation. Please use the overload that takes in the BatchRegistrationCallback instead.".TrimInside(), action); }