Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added check for null argument in NamedLikeFactoryMethod syntax extens…

…ion method
  • Loading branch information...
commit 087dfa139bdc35a917fcbe1137db89a9d968a470 1 parent b9d0b65
@ursenzler ursenzler authored
View
8 src/Ninject.Extensions.Factory.Test/FactoryTests.cs
@@ -102,6 +102,14 @@ public void NamedLikeFactoryMethodThrowsExceptionWhenNotAGetFactoryMethod()
}
[Fact]
+ public void NamedLikeFactoryMethodThrowsExceptionWhenActionIsNull()
+ {
+ Action action = () => this.kernel.Bind<IWeapon>().To<Sword>().NamedLikeFactoryMethod<Sword, ICustomizableWeapon>(null);
+
+ action.ShouldThrow<ArgumentNullException>();
+ }
+
+ [Fact]
public void GetFallback()
{
this.kernel.Bind<IWeapon>().To<Dagger>();
View
5 src/Ninject.Extensions.Factory/BindToExtensions.cs
@@ -100,6 +100,11 @@ public static IBindingWhenInNamedWithOrOnSyntax<object> ToFactory(this IBindingT
/// </returns>
public static IBindingWithOrOnSyntax<TInterface> NamedLikeFactoryMethod<TInterface, TFactory>(this IBindingNamedSyntax<TInterface> syntax, Expression<Action<TFactory>> action)
{
+ if (action == null)
+ {
+ throw new ArgumentNullException("action");
+ }
+
var methodCallExpression = action.Body as MethodCallExpression;
if (methodCallExpression == null)
Please sign in to comment.
Something went wrong with that request. Please try again.