Finds files recursevely in a directory
상속: IFileSystemHelper
예제 #1
0
        public void Find_ShouldSearchFileSystem()
        {
            var mockFilesystem = MockRepository.GenerateStub<IFileSystemWrapper>();
            var finder = new FileSystemHelper(mockFilesystem);

            string fileToSearchFor = "searchForMe.exe";
            mockFilesystem.Stub(x => x.GetFilesIn(Properties.CurrentDirectory)).Return(new[]
                                                                                            {
                                                                                                "test.txt",
                                                                                            });
            finder.Find(fileToSearchFor);
        }
예제 #2
0
        public void Find_ShouldSearchFileSystemRecursively()
        {
            var mockFilesystem = MockRepository.GenerateStub<IFileSystemWrapper>();
            var finder = new FileSystemHelper(mockFilesystem);

            string fileToSearchFor = "searchForMe.exe";
            mockFilesystem.Stub(x => x.GetFilesIn(Properties.CurrentDirectory)).Return(new[]
                                                                                            {
                                                                                                "test.txt",
                                                                                            });
            mockFilesystem.Stub(x => x.GetDirectories(Properties.CurrentDirectory)).Return(new[] {"src", "tools"});
            mockFilesystem.Stub(x => x.GetFilesIn("src")).Return(new[]
                                                                     {
                                                                         "test.txt",
                                                                     });
            mockFilesystem.Stub(x => x.GetFilesIn("tools")).Return(new[]
                                                                       {
                                                                           "test.txt",
                                                                           fileToSearchFor
                                                                       });
            Assert.That(finder.Find(fileToSearchFor),
                        Is.EqualTo(fileToSearchFor));
        }