Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test for IEnumerable dependencies for documentation purposes #41

Merged
merged 1 commit into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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