PageRenderTime 99ms CodeModel.GetById 16ms RepoModel.GetById 8ms app.codeStats 0ms

/src/Ninject.Tests/Integration/ConditionalBindingWhenParentTests.cs

https://github.com/developingchris/ninject
C# | 30 lines | 26 code | 4 blank | 0 comment | 0 complexity | 1f0b10dbf6b5893a7a7de528af1c4894 MD5 | raw file
  1. using Ninject.Tests.Fakes;
  2. using Xunit;
  3. using Xunit.Should;
  4. namespace Ninject.Tests.Integration
  5. {
  6. public class WhenParentContext
  7. {
  8. protected readonly StandardKernel kernel;
  9. public WhenParentContext()
  10. {
  11. kernel = new StandardKernel();
  12. kernel.Bind<Sword>().ToSelf().Named("Broken");
  13. kernel.Bind<Sword>().ToSelf().WhenParentNamed("Something");
  14. }
  15. }
  16. public class WhenParentNamed : WhenParentContext
  17. {
  18. [Fact]
  19. public void NamedInstanceAvailableEvenWithWhenBinding()
  20. {
  21. var instance = kernel.Get<Sword>("Broken");
  22. instance.ShouldNotBeNull();
  23. instance.ShouldBeInstanceOf(typeof(Sword));
  24. }
  25. }
  26. }