Esempio n. 1
0
        public void EnumerateFiles_should_match_files_nominal(string text)
        {
            var unit = GlobTemplate.Parse(text);
            var all  = unit.EnumerateFiles();

            Assert.HasCount(1, t => t.FileName.EndsWith("AssemblyInfo.cs"), all);
        }
Esempio n. 2
0
        public TestFileInput(string pathPattern)
        {
            if (pathPattern == null)
            {
                throw new ArgumentNullException(nameof(pathPattern));
            }
            PathPattern = pathPattern.Trim();

            // Patterns must not look like URLs
            if (!Regex.IsMatch(pathPattern, "^(data|http|https):"))
            {
                Pattern = GlobTemplate.Parse(pathPattern);
            }
            if (Pattern == null || Pattern.Variables.Count == 0)
            {
                // If the URI looks like a file, treat as one
                if (pathPattern.StartsWith("/", StringComparison.Ordinal))
                {
                    Url = new Uri("file://" + pathPattern);
                }
                else
                {
                    Url = new Uri(pathPattern, UriKind.RelativeOrAbsolute);
                }
            }
        }
Esempio n. 3
0
        public void Parse_should_generate_expected_values()
        {
            var unit = GlobTemplate.Parse("/var/{dir}/Suite");

            Assert.Equal("^.*/var/(?<dir>.*?)/Suite$", unit.Pattern.ToString());
            Assert.Contains("dir", unit.Variables);
            Assert.Equal(Glob.Parse("/var/*/Suite"), unit.Glob);
        }
        public void ToString_should_equal_filename()
        {
            var unit     = GlobTemplate.Parse("dotnet/src/Carbonfrost.Commons.Core/{name}/{file}.cs");
            var all      = unit.EnumerateFiles();
            var assembly = all.Single(t => t.FileName.EndsWith("AssemblyInfo.cs"));

            Assert.Equal(assembly.ToString(), assembly.FileName);
        }
Esempio n. 5
0
        public override object ConvertFromString(string text, Type destinationType, IValueSerializerContext context)
        {
            if (text != null)
            {
                return(GlobTemplate.Parse(text));
            }

            return(base.ConvertFromString(text, destinationType, context));
        }
Esempio n. 6
0
        public void EnumerateFiles_should_capture_variables(string text)
        {
            var unit = GlobTemplate.Parse(text);
            var all  = unit.EnumerateFiles();

            var assembly = all.Single(t => t.FileName.EndsWith("AssemblyInfo.cs"));

            Assert.Equal("Properties", assembly["name"]);
            Assert.Equal("AssemblyInfo", assembly["file"]);
            Assert.Equal("Properties", assembly.Data["name"]);
            Assert.Equal("AssemblyInfo", assembly.Data["file"]);

            Assert.Null(assembly["missing"]);
            Assert.Throws <KeyNotFoundException>(
                () => assembly.Data["missing"]
                );
        }
Esempio n. 7
0
        public void ToString_should_equal_Glob()
        {
            var unit = GlobTemplate.Parse("dotnet/src/Carbonfrost.Commons.Core/{name}/{file}.cs");

            Assert.Equal(unit.ToString(), unit.Glob.ToString());
        }
Esempio n. 8
0
        public void Parse_should_generate_from_pwd_dot(string text, string expected)
        {
            var unit = GlobTemplate.Parse(text);

            Assert.Equal(expected, unit.Pattern.ToString());
        }