public void DirectoryLoader_ShouldThrowException_IfDirectoryIsInvalid() { //Given var loader = new DirectoryLoader <TestAppEvents>(string.Empty); var events = new TestAppEvents(); // When & Then Assert.Throws <ArgumentException>(() => loader.Load(events)); }
/// <summary> /// This Method will update the ListView side of the window with all the folders and /// files which are in the selected Directory. /// </summary> /// <param name="info">A DirectoryInfo</param> private void FillFileListView(DirectoryInfo info) { filesListView.Items.Clear(); foreach (ListViewItem listViewItem in DirectoryLoader.LoadSelectedDirInfo(info)) { filesListView.Items.Add(listViewItem); } filesListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); }
public void LoadDirTestNumberOfFiles(int expectedFiles) { // Arrange var fileSystem = TestUtils.FileSystemBuilder(expectedFiles); var testee = new DirectoryLoader(fileSystem); // Act var actualFiles = testee.GetFiles("testDir").Length; // Assess Assert.AreEqual(expectedFiles, actualFiles); }
public override void OnInspectorGUI() { DrawDefaultInspector(); DirectoryLoader loaderscript = (DirectoryLoader)target; if (!EditorApplication.isPlaying) { if (GUILayout.Button("Load Directory")) { loaderscript.LoadAll(); } } }
public void DirectoryLoader_ShouldBindEvents_IfDirectoryIsValid() { //Given var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path1"); var loader = new DirectoryLoader <TestAppEvents>(path); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.NotNull(events.MyEvent); }
public void DirectoryLoader_ShouldLoadModules_IfModuleFilterIsValid() { //Given var path = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path3"); var loader = new DirectoryLoader <TestAppEvents>(path, moduleFilter: "*.mod"); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.True(modules.Any()); }
public void DirectoryLoader_ShouldLoadSubDirectories_IfRecurseiveIsSet() { //Given var path = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName; var loader = new DirectoryLoader <TestAppEvents>(path, true); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.True(modules.Any()); }
public void DirectoryLoader_ShouldLoadAllModules_IfMultipleDirectoriesAreProvided() { //Given var path1 = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path1"); var path2 = Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "Test.Modules", "Path2"); var loader = new DirectoryLoader <TestAppEvents>(new string[] { path1, path2 }); var events = new TestAppEvents(); //When var modules = loader.Load(events); //Then Assert.Equal(2, modules.Count()); }
public ApplicationContextImpl(IServiceCollection service) : base(service) { string pluginPath = System.IO.Path.Combine(AppContext.BaseDirectory, "Plugin"); if (!System.IO.Directory.Exists(pluginPath)) { System.IO.Directory.CreateDirectory(pluginPath); } ExceptionLogger = LoggerManager.GetLogger("PluginInitException"); //所有程序集 DirectoryLoader dl = new DirectoryLoader(); List <Assembly> assList = new List <Assembly>(); var psl = dl.LoadFromDirectory(pluginPath); assList.AddRange(psl); AdditionalAssembly = assList; }
public void WordSearchManager_Test() { // Arrange int expectedFiles = 20; int expectedMatchesPerFile = 5; var filesystem = TestUtils.FileSystemBuilder(expectedFiles, "pattern", expectedMatchesPerFile); var loadDirs = new DirectoryLoader(filesystem); var searchWords = new WordSearcher(filesystem); var testee = new WordSearchManager(loadDirs, searchWords); // Act var numberOfFiles = testee.LoadDirectory("testDir"); var topTen = testee.SearchMatches("pattern"); // Assert Assert.AreEqual(expectedFiles, numberOfFiles); Assert.AreEqual(10, topTen.Count); topTen.ToList().ForEach((kvp) => Assert.AreEqual(expectedMatchesPerFile, kvp.Value)); }
public CitySeeContextImpl(IServiceCollection serviceCollection) : base(serviceCollection) { string pluginConfigPath = System.IO.Path.Combine(AppContext.BaseDirectory, "PluginConfig"); if (!System.IO.Directory.Exists(pluginConfigPath)) { System.IO.Directory.CreateDirectory(pluginConfigPath); } string pluginPath = System.IO.Path.Combine(AppContext.BaseDirectory, "Plugin"); if (!System.IO.Directory.Exists(pluginPath)) { System.IO.Directory.CreateDirectory(pluginPath); } //所有程序集 DirectoryLoader dl = new DirectoryLoader(); List <Assembly> assList = new List <Assembly>(); var psl = dl.LoadFromDirectory(pluginPath); assList.AddRange(psl); AdditionalAssembly = assList; }
public RegisterDependencyType(IOptions <RegisterDependencyTypeOptions> options) { _options = options.Value; _loader = new DirectoryLoader(_options.AssemblyPathLocation); _thisAssemblyName = new AssemblyName(GetType().GetTypeInfo().Assembly.FullName); }
public static JavaScriptHostingConfig AddPluginFolder(this JavaScriptHostingConfig config, string folderPath) { var loader = new DirectoryLoader(folderPath); return(config.AddPluginLoader(loader.Load)); }