Ejemplo n.º 1
0
 public void TryParseTest_Single()
 {
     Assert.True(FfprobeSectionCollection.TryParse("Abc", out FfprobeSectionCollection r));
     Assert.Equal(1, r.Count);
     Assert.Equal("Abc", r[0].Name);
     Assert.Equal(0, r[0].Entries.Count);
 }
Ejemplo n.º 2
0
        public void TryParseTest_Multiple()
        {
            Assert.True(FfprobeSectionCollection.TryParse("Abc:Def=A1:Ghi=B2,C3", out FfprobeSectionCollection r));

            Assert.Equal(3, r.Count);
            Assert.Equal("Abc", r[0].Name);
            Assert.Equal(0, r[0].Entries.Count);

            Assert.Equal(3, r.Count);
            Assert.Equal("Def", r[1].Name);
            Assert.Equal(new[] { "A1" }, r[1].Entries);

            Assert.Equal(3, r.Count);
            Assert.Equal("Ghi", r[2].Name);
            Assert.Equal(new[] { "B2", "C3" }, r[2].Entries);
        }
Ejemplo n.º 3
0
        public static bool TryParse(string s, out FfprobeSectionCollection result)
        {
            if (string.IsNullOrEmpty(s))
            {
                result = null;
                return(true);
            }

            var si = 0;

            result = new FfprobeSectionCollection();

            var j = s.IndexOf(':', si);

            FfprobeSection sec;

            while (0 <= j && j < s.Length)
            {
                if (!FfprobeSection.TryParse(s, si, j - si, out sec))
                {
                    result = null;
                    return(false);
                }

                result.Add(sec);
                si = j + 1;
                j  = s.IndexOf(':', si);
            }

            if (!FfprobeSection.TryParse(s, si, s.Length - si, out sec))
            {
                result = null;
                return(false);
            }

            result.Add(sec);

            return(true);
        }
Ejemplo n.º 4
0
 public void TryParseTest_Null()
 {
     Assert.True(FfprobeSectionCollection.TryParse(null, out FfprobeSectionCollection r));
     Assert.Null(r);
 }