Find() public method

Finds a file in the CURRENT directory and searches subdirectories
public Find ( string fileName ) : string
fileName string The filename to search for
return string
Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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));
        }