コード例 #1
0
        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);
 }
コード例 #3
0
ファイル: LoadDirTests.cs プロジェクト: ebellon/WordSearcher
        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);
        }
コード例 #4
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        DirectoryLoader loaderscript = (DirectoryLoader)target;

        if (!EditorApplication.isPlaying)
        {
            if (GUILayout.Button("Load Directory"))
            {
                loaderscript.LoadAll();
            }
        }
    }
コード例 #5
0
        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);
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        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());
        }
コード例 #8
0
        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());
        }
コード例 #9
0
        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;
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        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;
        }
コード例 #12
0
 public RegisterDependencyType(IOptions <RegisterDependencyTypeOptions> options)
 {
     _options          = options.Value;
     _loader           = new DirectoryLoader(_options.AssemblyPathLocation);
     _thisAssemblyName = new AssemblyName(GetType().GetTypeInfo().Assembly.FullName);
 }
コード例 #13
0
        public static JavaScriptHostingConfig AddPluginFolder(this JavaScriptHostingConfig config, string folderPath)
        {
            var loader = new DirectoryLoader(folderPath);

            return(config.AddPluginLoader(loader.Load));
        }