Skip to content

Commit

Permalink
Merge pull request grumpydev#41 from richardhopton/Tests/IEnumerable
Browse files Browse the repository at this point in the history
Added test for IEnumerable dependencies for documentation purposes
  • Loading branch information
niemyjski authored Apr 19, 2018
2 parents addd4fe + 17b74da commit c648382
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/TinyIoC.Tests/TestData/NestedInterfaceDependencies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ public bool LoadView(IView view)

}

public class ViewCollection
{
private readonly IEnumerable<IView> _views;

public ViewCollection(IEnumerable<IView> views)
{
_views = views;
}

public IEnumerable<IView> Views
{
get { return _views; }
}
}

public class SplashView : IView
{
public object GetView()
Expand Down
11 changes: 11 additions & 0 deletions src/TinyIoC.Tests/TinyIoCFunctionalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,17 @@ public void Dependency_Hierarchy_With_Named_Factories_Resolves_All_Correctly()
Assert.IsInstanceOfType(mainView.LoadedView, typeof(SplashView));
}

[TestMethod]
public void Dependency_Hierarchy_Resolves_IEnumerable_Correctly()
{
var container = UtilityMethods.GetContainer();
var mainView = new MainView();
container.Register<IView, MainView>(mainView, "MainView");
container.Register<IView, SplashView>("SplashView").UsingConstructor(() => new SplashView());
var viewCollection = container.Resolve<ViewCollection>();
Assert.AreEqual(viewCollection.Views.Count(), 2);
}

[TestMethod]
public void When_Unable_To_Resolve_Nested_Dependency_Should_Include_That_Type_In_The_Exception()
{
Expand Down

0 comments on commit c648382

Please sign in to comment.