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

Language C# Lines 39
MD5 Hash e9f93052ecbca662d6fcc0536d317e73
Repository https://github.com/developingchris/ninject.git View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Ninject.Activation.Blocks;
using Ninject.Tests.Fakes;
using Xunit;
using Xunit.Should;

namespace Ninject.Tests.Integration.ModuleLoadingTests
{
	public class ModuleLoadingContext
	{
		protected readonly StandardKernel kernel;
		protected readonly string assemblyFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"TestModules\Ninject.Tests.TestModule.dll");

		public ModuleLoadingContext()
		{
			kernel = new StandardKernel();
		}
	}

	public class WhenLoadIsCalledWithAssemblies : ModuleLoadingContext
	{
		[Fact]
		public void ModulesContainedInAssembliesAreLoaded()
		{
			var assembly = Assembly.Load(new AssemblyName { CodeBase = assemblyFilename });

			kernel.Load(assembly);

			var modules = kernel.GetModules().ToArray();

			modules.ShouldNotBeEmpty();
			modules[0].ShouldBeInstanceOf(assembly.GetType("Ninject.Tests.TestModules.TestModule"));
			modules[0].Kernel.ShouldBe(kernel);
		}
	}
}
Back to Top