Skip to content

Commit

Permalink
Fixed that the wrong error message is shown when there are multiple b…
Browse files Browse the repository at this point in the history
…indings for a unique request.
  • Loading branch information
remogloor committed Nov 17, 2010
1 parent 592932d commit 04bebff
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion UnzipDependencies.cmd
@@ -1,5 +1,5 @@
tools\nant\nant.exe -buildfile:Ninject.build UnzipDependencies %1 %2 %3 %4 %5 %6 %7 %8

if %NoPause%=="true" goto ENDBATCHFILE
if "%NoPause%"=="true" goto ENDBATCHFILE
pause
:ENDBATCHFILE
2 changes: 1 addition & 1 deletion build-release.cmd
Expand Up @@ -24,6 +24,6 @@ echo "BUILD FAILED"
echo "============================================================"

:End
if %NoPause%=="true" goto ENDBATCHFILE
if "%NoPause%"=="true" goto ENDBATCHFILE
pause
:ENDBATCHFILE
15 changes: 13 additions & 2 deletions src/Ninject.Test/Integration/StandardKernelTests.cs
Expand Up @@ -56,8 +56,19 @@ public void ActivationExceptionThrownWhenMultipleBindingsAreRegistered()
{
kernel.Bind<IWeapon>().To<Sword>();
kernel.Bind<IWeapon>().To<Shuriken>();

Assert.Throws<ActivationException>(() => kernel.Get<IWeapon>());
ActivationException exception = null;

try
{
kernel.Get<IWeapon>();
}
catch (ActivationException e)
{
exception = e;
}

exception.ShouldNotBeNull();
exception.Message.ShouldContain("More than one matching bindings are available.");
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion src/Ninject/KernelBase.cs
Expand Up @@ -364,7 +364,7 @@ public virtual IEnumerable<object> Resolve(IRequest request)
return Enumerable.Empty<object>();
}

throw new ActivationException(ExceptionFormatter.CouldNotResolveBinding(request));
throw new ActivationException(ExceptionFormatter.CouldNotUniquelyResolveBinding(request));
}

return bindings.Select(binding => this.CreateContext(request, binding)).Select(context => context.Resolve());
Expand Down

0 comments on commit 04bebff

Please sign in to comment.