public void Use_type_filter() { var dir = Assembly.GetExecutingAssembly().GetDirectory(); var expected = typeof(SafeDirectoryCatalog_Should); using (var sut = new SafeDirectoryCatalog(dir, type => type == expected)) { var part = sut.Parts.Single(); part.ToString().Should().Be(expected.FullName); } }
private void AddCatalogFor(string libDir) { if (CatalogsMatching(libDir).Any()) { return; } var catalog = new SafeDirectoryCatalog(libDir, TypeFilter, Conventions, ConsiderFile); if (!catalog.Parts.Any()) { return; } _catalog.Catalogs.Add(catalog); _assemblyFiles.AddRange(catalog.Assemblies.Select(a => a.GetLocation())); }
public void Use_file_filter() { var assembly = Assembly.GetExecutingAssembly(); var dir = assembly.GetDirectory(); // without file filter we load n assemblies using (var sut = new SafeDirectoryCatalog(dir)) sut.Catalog.Catalogs.Should().NotBeNullOrEmpty(); // exactly our assembly var assemblyFileName = assembly.GetLocation(); using (var sut = new SafeDirectoryCatalog(dir, fileFilter: fileName => fileName.Equals(assemblyFileName, StringComparison.InvariantCultureIgnoreCase))) { var catalog = sut.Catalog.Catalogs.OfType <SafeAssemblyCatalog>().Single(); catalog.Assembly.FullName.Should().Be(assembly.FullName); } // no assembly using (var sut = new SafeDirectoryCatalog(dir, fileFilter: fileName => false)) sut.Catalog.Catalogs.Should().BeEmpty("file filter cannot match."); }