PageRenderTime 50ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/src/Ninject.Tests/Integration/ModuleLoadingTests.cs

https://github.com/developingchris/ninject
C# | 39 lines | 33 code | 6 blank | 0 comment | 0 complexity | 1bb33f8e8d90597a94ac1b6efdd7ae19 MD5 | raw file
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Ninject.Activation.Blocks;
  6. using Ninject.Tests.Fakes;
  7. using Xunit;
  8. using Xunit.Should;
  9. namespace Ninject.Tests.Integration.ModuleLoadingTests
  10. {
  11. public class ModuleLoadingContext
  12. {
  13. protected readonly StandardKernel kernel;
  14. protected readonly string assemblyFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"TestModules\Ninject.Tests.TestModule.dll");
  15. public ModuleLoadingContext()
  16. {
  17. kernel = new StandardKernel();
  18. }
  19. }
  20. public class WhenLoadIsCalledWithAssemblies : ModuleLoadingContext
  21. {
  22. [Fact]
  23. public void ModulesContainedInAssembliesAreLoaded()
  24. {
  25. var assembly = Assembly.Load(new AssemblyName { CodeBase = assemblyFilename });
  26. kernel.Load(assembly);
  27. var modules = kernel.GetModules().ToArray();
  28. modules.ShouldNotBeEmpty();
  29. modules[0].ShouldBeInstanceOf(assembly.GetType("Ninject.Tests.TestModules.TestModule"));
  30. modules[0].Kernel.ShouldBe(kernel);
  31. }
  32. }
  33. }