コード例 #1
0
        public void GetPackageDirectory()
        {
            // Test only makes sense if run as part of the NUnit solution
            string solutionDir = _baseDir.Parent.Parent.FullName;

            Assume.That(File.Exists(Path.Combine(solutionDir, "nunit.sln")));

            string expected = Path.Combine(solutionDir, "packages");

            Assert.That(DirectoryFinder.GetPackageDirectory(_baseDir).FullName, Is.EqualTo(expected));
        }
コード例 #2
0
        /// <summary>
        /// Get files using an extended pattern with the option of wildcard
        /// characters in each path component.
        /// </summary>
        /// <param name="baseDir">A DirectoryInfo from which the matching starts</param>
        /// <param name="pattern">The pattern to match</param>
        /// <returns>A list of FileInfos</returns>
        public static IList <FileInfo> GetFiles(DirectoryInfo baseDir, string pattern)
        {
            // If there is no directory path in pattern, delegate to DirectoryInfo
            int lastSep = pattern.LastIndexOf('/');

            if (lastSep < 0) // Simple file name entry, no path
            {
                return(baseDir.GetFiles(pattern));
            }

            // Otherwise split pattern into two parts around last separator
            var pattern1 = pattern.Substring(0, lastSep);
            var pattern2 = pattern.Substring(lastSep + 1);

            var fileList = new List <FileInfo>();

            foreach (var dir in DirectoryFinder.GetDirectories(baseDir, pattern1))
            {
                fileList.AddRange(dir.GetFiles(pattern2));
            }

            return(fileList);
        }
コード例 #3
0
        //[TestCase("net-4.0/nunit.framework.dll", 1)]
        //[TestCase("net-*/nunit.framework.dll", 4)]
        //[TestCase("net-*/*.framework.dll", 4)]
        //[TestCase("*/v2-tests/*.dll", 2)]
        //[TestCase("add*/v?-*/*.dll", 2)]
        //[TestCase("**/v2-tests/*.dll", 2)]
        //[TestCase("addins/**/*.dll", 10)]
        //[TestCase("addins/../net-*/nunit.framework.dll", 4)]
        public void GetFiles(string pattern, int count)
        {
            var files = DirectoryFinder.GetFiles(_baseDir, pattern);

            Assert.That(files.Count, Is.EqualTo(count));
        }
コード例 #4
0
        // TODO: These tests are fragile because they rely on the directory structure
        // of the project itself - we should find a better way to test.

        //[TestCase("addins", 1)]
        //[TestCase("net-*", 4)]
        //[TestCase("*/v2-tests", 1)]
        //[TestCase("add*/v?-*", 1)]
        //[TestCase("**/v2-tests", 1)]
        //[TestCase("addins/**", 2)]
        //[TestCase("addins/../net-*", 4)]
        //[TestCase("addins/v2-tests/", 1)]
        //[TestCase("addins//v2-tests/", 1)]
        //[TestCase("addins/./v2-tests/", 1)]
        public void GetDirectories(string pattern, int count)
        {
            var dirList = DirectoryFinder.GetDirectories(_baseDir, pattern);

            Assert.That(dirList.Count, Is.EqualTo(count));
        }