Exemplo n.º 1
0
        private static Exception _TryParse(string text, out TestTag result)
        {
            if (text == null)
            {
                result = new TestTag();
                return(new ArgumentNullException());
            }

            text = text ?? string.Empty;
            if (text.Length == 0)
            {
                result = new TestTag();
                return(SpecFailure.AllWhitespace(nameof(text)));
            }
            string[] nv = Array.ConvertAll(
                text.Split(new [] { ':' }, 3), t => t.Trim()
                );
            if (nv.Length == 1 && ValidName(nv[0]))
            {
                result = new TestTag(nv[0].Trim());
                return(null);
            }
            if (nv.Length == 2 && ValidName(nv[0]) && ValidName(nv[1]))
            {
                result = new TestTag(nv[0].Trim(), nv[1].Trim());
                return(null);
            }

            result = new TestTag();
            return(new FormatException());
        }
Exemplo n.º 2
0
        private static Exception _TryParse(string text, out TestTagType result)
        {
            result = default(TestTagType);
            if (text == null)
            {
                return(new ArgumentNullException(nameof(text)));
            }

            text = text.Trim();
            if (text.Length == 0)
            {
                return(SpecFailure.AllWhitespace(nameof(text)));
            }

            if (_canonicalNames.TryGetValue(text, out string canonical))
            {
                text = canonical;
            }
            else
            {
                _canonicalNames.Add(text, text);
            }
            result = new TestTagType(text, false);
            return(null);
        }