Beispiel #1
0
        /// <summary>
        /// Parse a string representation of a TestName,
        /// returning a TestName.
        /// </summary>
        /// <param name="s">The string to parse</param>
        /// <returns>A TestName</returns>
        public static TestName Parse(string s)
        {
            if (s == null)
            {
                throw new ArgumentNullException("s", "Cannot parse a null string");
            }

            TestName testName = new TestName();

            testName.FullName = testName.Name = s;

            if (s.StartsWith("["))
            {
                int rbrack = s.IndexOf("]");
                if (rbrack < 0 || rbrack == s.Length - 1)
                {
                    throw new FormatException("Invalid TestName format: " + s);
                }

                testName.FullName = testName.Name = s.Substring(rbrack + 1);

                int dash = s.IndexOf("-");
                if (dash < 0 || dash > rbrack)
                {
                    testName.RunnerID = Int32.Parse(s.Substring(1, rbrack - 1));
                }
                else
                {
                    testName.RunnerID = Int32.Parse(s.Substring(1, dash - 1));
                    testName.TestID   = TestID.Parse(s.Substring(dash + 1, rbrack - dash - 1));
                }
            }

            return(testName);
        }
Beispiel #2
0
        /// <summary>
        /// Override of Equals method to allow comparison of TestIDs
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            TestID other = obj as TestID;

            if (other != null)
            {
                return(this.id == other.id);
            }

            return(base.Equals(obj));
        }