Permalink
Browse files

added check for null argument in NamedLikeFactoryMethod syntax extens…

…ion method
  • Loading branch information...
ursenzler committed May 21, 2012
1 parent b9d0b65 commit 087dfa139bdc35a917fcbe1137db89a9d968a470
@@ -101,6 +101,14 @@ public void NamedLikeFactoryMethodThrowsExceptionWhenNotAGetFactoryMethod()
action.ShouldThrow<ArgumentException>();
}
+ [Fact]
+ public void NamedLikeFactoryMethodThrowsExceptionWhenActionIsNull()
+ {
+ Action action = () => this.kernel.Bind<IWeapon>().To<Sword>().NamedLikeFactoryMethod<Sword, ICustomizableWeapon>(null);
+
+ action.ShouldThrow<ArgumentNullException>();
+ }
+
[Fact]
public void GetFallback()
{
@@ -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)

0 comments on commit 087dfa1

Please sign in to comment.