Ejemplo n.º 1
0
        public void TestMatching()
        {
            var root     = Environment.CurrentDirectory + @"\..\..\..\";
            var regex    = @"\.txt";
            var contents = @"(\d{5})\s([a-z|A-Z]+)";

            var results = new FileLocator().FindInFiles(root, regex, contents, true);

            Assert.AreEqual(2, results.Count());
            Assert.AreEqual(3, results.ElementAt(0).CaptureGroups.Count());
        }
Ejemplo n.º 2
0
        public void TestSolutionFileLocation()
        {
            // Test to find the .sln file in this solution.
            var root  = Environment.CurrentDirectory + @"\..\..\..\";
            var regex = ".sln$";
            var recur = false;

            // Verify one result, and the exact file path.
            var files = new FileLocator().FindFiles(root, regex, recur);

            Assert.AreEqual(1, files.Count());
        }
Ejemplo n.º 3
0
        public void TestFileContents()
        {
            // Test the location of the string 'TestFileContents'
            var root     = Environment.CurrentDirectory + @"\..\..\..\";
            var regex    = ".cs$";
            var contents = "TestFileContents";

            // Verify three locations found.
            var results = new FileLocator().FindInFiles(root, regex, contents, true);

            Assert.AreEqual(3, results.Count());

            // Verity no locations found without recursive sub directories.
            results = new FileLocator().FindInFiles(root, regex, contents, false);
            Assert.AreEqual(0, results.Count());
        }