PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Ninject.Tests/Unit/CompiledModuleLoaderPluginTests.cs

https://github.com/ALyman/ninject
C# | 42 lines | 37 code | 5 blank | 0 comment | 0 complexity | a3e1ae170e452dfb829ae9cdf6583a89 MD5 | raw file
  1. #if !NO_ASSEMBLY_SCANNING
  2. using System;
  3. using System.CodeDom.Compiler;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Reflection;
  8. using Moq;
  9. using Ninject.Modules;
  10. using Xunit;
  11. using Xunit.Should;
  12. namespace Ninject.Tests.Unit.CompiledModuleLoaderPluginTests
  13. {
  14. public class CompiledModuleLoaderPluginContext
  15. {
  16. protected readonly CompiledModuleLoaderPlugin loaderPlugin;
  17. protected readonly Mock<IKernel> kernelMock;
  18. protected readonly string assemblyFilename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"TestModules\Ninject.Tests.TestModule.dll");
  19. public CompiledModuleLoaderPluginContext()
  20. {
  21. kernelMock = new Mock<IKernel>();
  22. loaderPlugin = new CompiledModuleLoaderPlugin(kernelMock.Object);
  23. }
  24. }
  25. public class WhenLoadModulesIsCalled : CompiledModuleLoaderPluginContext
  26. {
  27. [Fact(Skip = "Need to bring TestModule assembly into git")]
  28. public void CallsLoadMethodOnKernelWithAssemblies()
  29. {
  30. Assembly expected = Assembly.Load("Ninject.Tests.TestModule");
  31. expected.ShouldNotBeNull();
  32. loaderPlugin.LoadModules(new[] { assemblyFilename });
  33. kernelMock.Verify(x => x.Load(It.Is<IEnumerable<Assembly>>(p => p.Contains(expected))));
  34. }
  35. }
  36. }
  37. #endif //!NO_ASSEMBLY_SCANNING