Skip to content

Commit

Permalink
passing test for the #555
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Feb 13, 2023
1 parent 385f4df commit e22d9a3
Showing 1 changed file with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ public class GHIssue506_WithConcreteTypeDynamicRegistrations_hides_failed_depend
{
public int Run()
{
Test();
return 1;
// Test1();
Test2();
return 2;
}

[Test]
public void Test()
public void Test1()
{
var containerWithNiceException = new Container();
containerWithNiceException.Register<Service>();

const string expected = @"as parameter ""dependency""";

var ex = Assert.Throws<ContainerException>(() => containerWithNiceException.Resolve<Service>());

const string expected = @"as parameter ""dependency""";
StringAssert.Contains(expected, ex.Message);

var containerWithAutoConcreteTypes = new Container(rules => rules.WithConcreteTypeDynamicRegistrations(IfUnresolved.Throw, reuse: Reuse.Transient));
Expand All @@ -29,6 +30,14 @@ public void Test()
StringAssert.Contains(expected, ex2.Message);
}

[Test]
public void Test2()
{
var c = new Container(Rules.MicrosoftDependencyInjectionRules.WithConcreteTypeDynamicRegistrations());
var o = c.Resolve<OtherService>();
Assert.IsNotNull(o.Dependency);
}

internal class Service
{
public Service(IDependency dependency)
Expand All @@ -39,5 +48,15 @@ public Service(IDependency dependency)
internal interface IDependency
{
}

internal class Dependency : IDependency
{
}

internal class OtherService
{
public readonly Dependency Dependency;
public OtherService(Dependency dependency) => Dependency = dependency;
}
}
}

0 comments on commit e22d9a3

Please sign in to comment.