diff --git a/src/Ninject.Test/Integration/ReadOnlyKernelTests.cs b/src/Ninject.Test/Integration/ReadOnlyKernelTests.cs index f8015ad2..174ed6da 100644 --- a/src/Ninject.Test/Integration/ReadOnlyKernelTests.cs +++ b/src/Ninject.Test/Integration/ReadOnlyKernelTests.cs @@ -360,8 +360,8 @@ public void TryGet_ServiceAndParameters() bindings.Should().OnlyContain(b => !b.IsImplicit); } - [Fact(Skip = "Unique?")] - public void TryGet_ServiceAndNameAndParameters_ResolvesUsingFirstMatchingBindingWhenTypeIsSelfBinding() + [Fact()] + public void TryGet_ServiceAndNameAndParameters_WhenTypeIsSelfBinding() { var service = typeof(Sword); @@ -371,8 +371,7 @@ public void TryGet_ServiceAndNameAndParameters_ResolvesUsingFirstMatchingBinding Kernel = Configuration.BuildReadOnlyKernel(); var weapon = Kernel.TryGet(service, "a", Array.Empty()); - weapon.Should().NotBeNull(); - weapon.Should().BeOfType(); + weapon.Should().BeNull(); var bindings = Kernel.GetBindings(service); bindings.Should().HaveCount(2); @@ -380,8 +379,8 @@ public void TryGet_ServiceAndNameAndParameters_ResolvesUsingFirstMatchingBinding } - [Fact(Skip = "Unique?")] - public void TryGet_ServiceAndNameAndParameters_ResolvesUsingFirstMatchingBindingWhenTypeIsNotSelfBinding() + [Fact()] + public void TryGet_ServiceAndNameAndParameters_WhenTypeIsNotSelfBinding() { var service = typeof(IWeapon); @@ -391,16 +390,15 @@ public void TryGet_ServiceAndNameAndParameters_ResolvesUsingFirstMatchingBinding Kernel = Configuration.BuildReadOnlyKernel(); var weapon = Kernel.TryGet(service, "a", Array.Empty()); - weapon.Should().NotBeNull(); - weapon.Should().BeOfType(); + weapon.Should().BeNull(); var bindings = Kernel.GetBindings(service); bindings.Should().HaveCount(2); bindings.Should().OnlyContain(b => !b.IsImplicit); } - [Fact(Skip = "Unique?")] - public void TryGet_ServiceAndConstraintAndParameters_ResolvesUsingFirstMatchingBindingWhenTypeIsSelfBinding() + [Fact()] + public void TryGet_ServiceAndConstraintAndParameters_WhenTypeIsSelfBinding() { var service = typeof(Sword); @@ -412,16 +410,15 @@ public void TryGet_ServiceAndConstraintAndParameters_ResolvesUsingFirstMatchingB var weapon = Kernel.TryGet(service, (metadata) => metadata.Name == "a", Array.Empty()); - weapon.Should().NotBeNull(); - weapon.Should().BeOfType(); + weapon.Should().BeNull(); var bindings = Kernel.GetBindings(service); bindings.Should().HaveCount(3); bindings.Should().OnlyContain(b => !b.IsImplicit); } - [Fact(Skip ="Unique?")] - public void TryGet_ServiceAndConstraintAndParameters_ResolvesUsingFirstMatchingBindingWhenTypeIsNotSelfBindingAndNotGeneric() + [Fact()] + public void TryGet_ServiceAndConstraintAndParameters_WhenTypeIsNotSelfBindingAndNotGeneric() { var service = typeof(IWeapon); @@ -432,8 +429,7 @@ public void TryGet_ServiceAndConstraintAndParameters_ResolvesUsingFirstMatchingB var weapon = Kernel.TryGet(service, (metadata) => metadata.Name == "a", Array.Empty()); - weapon.Should().NotBeNull(); - weapon.Should().BeOfType(); + weapon.Should().BeNull(); var bindings = Kernel.GetBindings(service); bindings.Should().HaveCount(2); diff --git a/src/Ninject/Syntax/ResolutionExtensions.cs b/src/Ninject/Syntax/ResolutionExtensions.cs index bd3d2249..3c4f3827 100644 --- a/src/Ninject/Syntax/ResolutionExtensions.cs +++ b/src/Ninject/Syntax/ResolutionExtensions.cs @@ -281,7 +281,7 @@ public static object TryGet(this IResolutionRoot root, Type service, params IPar /// public static object TryGet(this IResolutionRoot root, Type service, string name, params IParameter[] parameters) { - return TryGet(() => ResolveSingle(root, service, b => b.Name == name, parameters, true, false)); + return TryGet(() => ResolveSingle(root, service, b => b.Name == name, parameters, true, true)); } /// @@ -296,7 +296,7 @@ public static object TryGet(this IResolutionRoot root, Type service, string name /// public static object TryGet(this IResolutionRoot root, Type service, Func constraint, params IParameter[] parameters) { - return TryGet(() => ResolveSingle(root, service, constraint, parameters, true, false)); + return TryGet(() => ResolveSingle(root, service, constraint, parameters, true, true)); } ///