Skip to content

Commit

Permalink
adding the another Enumerable test
Browse files Browse the repository at this point in the history
  • Loading branch information
dadhi committed Jun 14, 2021
1 parent cdeb834 commit a4c090e
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions test/DryIoc.UnitTests/EnumerableAndArrayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,40 @@ public void Can_resolve_array_of_asResolutionCall_service()
}

class N { }

[Test]
public void Inject_Enumerable_in_the_class_with_the_base_constructor()
{
var container = new Container();

container.Register<ISomething, Something1>();
container.Register<ISomething, Something2>();

container.Register<SomethingElse>();
container.Register<ISomethingRegistry, SomethingRegistry>();

var registry1 = container.Resolve<SomethingElse>();
Assert.AreEqual(2, registry1.Somethings.Count());

var registry2 = container.Resolve<ISomethingRegistry>();
Assert.AreEqual(2, registry2.Somethings.Count());
}

public interface ISomething {}
public class Something1 : ISomething {}
public class Something2 : ISomething {}
public interface ISomethingRegistry
{
IEnumerable<ISomething> Somethings { get; }
}
public class SomethingElse : ISomethingRegistry
{
public IEnumerable<ISomething> Somethings { get; }
public SomethingElse(IEnumerable<ISomething> somethings = null) => Somethings = somethings;
}
public class SomethingRegistry : SomethingElse
{
public SomethingRegistry(IEnumerable<ISomething> somethings = null) : base(somethings) {}
}
}
}

0 comments on commit a4c090e

Please sign in to comment.