/src/Ninject.Test/Unit/AssemblyNameRetrieverTests.cs
C# | 49 lines | 42 code | 7 blank | 0 comment | 0 complexity | 2dfd3a35e4f3e291f04123710f562c7a MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, BSD-3-Clause
- namespace Ninject.Tests.Unit
- {
- using System;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using FluentAssertions;
- using Ninject.Modules;
- using Xunit;
- public class AssemblyNameRetrieverContext
- {
- protected readonly AssemblyNameRetriever AssemblyNameRetriever;
- protected readonly string ModuleFilename = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"Ninject.Tests.TestModule.dll");
- protected readonly string AssemblyFilename = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath), @"Ninject.Tests.TestAssembly.dll");
- public AssemblyNameRetrieverContext()
- {
- this.AssemblyNameRetriever = new AssemblyNameRetriever();
- }
- }
- public class WhenGetAssemblyNamesIsCalledWithFileName : AssemblyNameRetrieverContext
- {
- [Fact]
- public void AssemblyNamesOfMatchingAssembliesAreReturned()
- {
- var expected = Assembly.LoadFrom(this.ModuleFilename).GetName();
- var actualNames = this.AssemblyNameRetriever.GetAssemblyNames(
- new[] { this.ModuleFilename, this.AssemblyFilename },
- asm => asm.FullName.StartsWith("Ninject.Tests.TestModule"));
- var assemblyFullNames = actualNames.Select(a => a.FullName).ToList();
- assemblyFullNames.Should().BeEquivalentTo(new[] { expected.FullName });
- }
- }
- public class WhenGetAssemblyNamesIsCalledWithUnknownAssemblyName : AssemblyNameRetrieverContext
- {
- [Fact]
- public void WillBeIgnored()
- {
- var actualNames = this.AssemblyNameRetriever.GetAssemblyNames(new[] { "Blah" }, asm => true);
- actualNames.Should().BeEmpty();
- }
- }
- }