public void Given_ModuleName_When_Valid_Then_ModuleReturned() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module1"); Assert.True(modules.Any(m => m.Name == "Module1")); }
public void Given_ModuleLocation_When_Invalid_Then_ThrowsDirectoryNotFoundException() { Assert.Throws <DirectoryNotFoundException>(() => { var modules = new NugetyCatalog() .FromDirectory("InvalidDirectory") .GetModules <IModuleInitializer>(); }); }
public void Given_FileNameFilterPattern_When_Valid_Then_ModuleReturned() { var modules = new NugetyCatalog() .Options.SetModuleFileNameFilter("*Module1") .FromDirectory() .GetModules <IModuleInitializer>(); Assert.True(!modules.Any(m => m.Name == "Module1")); }
public void Given_ModuleLocation_When_Valid_Then_ModuleReturned() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>(); Assert.True(modules.Any(m => m.Name == "Module1")); Assert.True(modules.Any(m => m.Name == "Module2 with dependency1 v0")); Assert.True(modules.Any(m => m.Name == "Module2 without dependency1")); }
public void Given_Initializer_When_Invalid_Then_NoInstancesReturned() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <InvalidInterface>("Module1"); var instances = modules.Load(); Assert.True(!instances.OfType <InvalidInterface>().Any()); }
public void Given_Initializer_When_Valid_Then_ModuleInstanceReturned() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module1"); var instances = modules.Load(); Assert.True(instances.OfType <IModuleInitializer>().Any()); }
public void Given_ModuleName_When_InValid_Then_ThrowsDirectoryNotFoundException() { var exception = Assert.Throws <DirectoryNotFoundException>(() => { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("InvalidModule1", "InvalidModule2"); }); Assert.Equal("Module Directory not found for 'InvalidModule1,InvalidModule2'", exception.Message); }
public void Given_GetManyModules_When_Valid_Then_ModulesReturned() { var modules = new NugetyCatalog().GetMany ( c => c.FromDirectory().GetModules <IModuleInitializer>("Module1"), c => c.FromDirectory().GetModules <IModuleInitializer>("Module2 with dependency1 v0") ); Assert.True(modules.Any(m => m.Name == "Module1")); Assert.True(modules.Any(m => m.Name == "Module2 with dependency1 v0")); }
public void Given_Dependency_When_Exists_Then_ModuleReturned() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module2 with dependency1 v0"); var instances = modules.Load(); Assert.True(modules.Any(m => m.Name == "Module2 with dependency1 v0")); Assert.True(instances.OfType <IModuleInitializer>().Any()); }
public static void Main(string[] args) { var modules = new NugetyCatalog() .Options.SetModuleFileNameFilter("*Module*.dll") .FromDirectory() .GetModules <IModuleInitializer>(); var instances = modules.Load(); instances.FirstOrDefault().ConfigureServices(null); }
public void Given_Dependency_When_DoesNotExist_Then_ThrowsException() { Assert.Throws <FileNotFoundException>(() => { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module2 without dependency1"); var instance = modules.Load().OfType <IDependency1Version>().FirstOrDefault(); instance.GetDependency1Type(); }); }
public void Given_TwoModules_When_HasSameDependencyDifferentVersion_Then_BothVersionsLoad() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module2 with dependency1 v0", "Module3 with dependency1 v1"); Assert.True(modules.Count() == 2); var instances = modules.Load().OfType <IDependency1Version>(); Assert.True(instances.Count() == 2); var names = instances.Select(i => i.GetDependency1Type().GetTypeInfo().AssemblyQualifiedName); Assert.True(names.Any(n => n.Contains("1.0.0.0")), "Module2 did not load Dependency1 version '1.0.0.0'"); Assert.True(names.Any(n => n.Contains("1.0.1.0")), "Module3 did not load Dependency1 version '1.0.1.0'"); }
public void Given_Module_When_Valid_Then_PropertiesPopulated() { var modules = new NugetyCatalog() .FromDirectory() .GetModules <IModuleInitializer>("Module1"); var module = modules.FirstOrDefault(m => m.Name == "Module1"); Assert.True(module != null); Assert.NotNull(module.Catalog); Assert.NotNull(module.ModuleInitialiser); Assert.True(!string.IsNullOrEmpty(module.Location)); Assert.NotNull(module.AssemblyInfo); Assert.NotNull(module.AssemblyInfo.Assembly); Assert.NotNull(module.AssemblyInfo.Context); Assert.True(!string.IsNullOrEmpty(module.AssemblyInfo.Location)); }
public NugetyOptions(NugetyCatalog catalog) { _catalog = catalog; this.IgnoreLoaderExceptions = true; }