Пример #1
0
        public void ListFilesGetsAllFilesInDirectory()
        {
            Directory.CreateDirectory("foo");
            File.WriteAllText("foo\\file1", "1");
            File.WriteAllText("foo\\file2", "2");
            var files = _search.ListFiles("foo").ToList();

            Assert.AreEqual(2, files.Count);
            Assert.AreEqual("file1", files[0]);
            Assert.AreEqual("file2", files[1]);
        }
Пример #2
0
        public ActionResult ListFiles() =>
        InDirectory(path =>
                    WithRegex(regex =>
        {
            var fileNames = _directorySearch.ListFiles(path);

            ViewModel.SourceItems =
                string.IsNullOrWhiteSpace(ViewModel.Filter)
                            ? fileNames.ToList()
                            : _filter.Filter(regex, fileNames).ToList();

            ViewModel.TargetItems =
                string.IsNullOrWhiteSpace(ViewModel.Template)
                            ? ViewModel.SourceItems.ToList()
                            : _renamer.Rename(ViewModel.Template, ViewModel.SourceItems).ToList();

            return(ActionResult.Ok);
        }));