예제 #1
0
        public static void AssertContainsTrace(string testName, string consoleOutput, string expectedTrace)
        {
            string resetMarker = "{{<<RESET>>}}";
            string tracePattern = @"<<\{\{(.*)}}>>";

            var lastReset = consoleOutput.LastIndexOf(resetMarker);

            if (lastReset < 0)
                lastReset = 0;
            else
                lastReset = lastReset + resetMarker.Length;

            MatchCollection matches = new Regex(tracePattern).Matches(consoleOutput, lastReset);

            var trace = matches.OfType<Match>().Select(m => m.Groups[1].Value).ToArray();

            Assert.That(trace, Is.EquivalentTo(expectedTrace.Split(new[] {'\n', '\r'}, StringSplitOptions.RemoveEmptyEntries)),
                "Did not find expected trace in " + testName);
        }
예제 #2
0
파일: ElvinURI.cs 프로젝트: renber/AvisNet
        /// <summary>
        /// 
        /// </summary>
        /// <param name="optionsExpr"></param>
        /// <exception cref="UriFormatException"></exception>
        private void ParseOptions(String optionsExpr)
        {
            var optionMatch = new Regex(";([^=;]+)=([^=;]*)").Matches(optionsExpr);

            Options = new Dictionary<String, String>();

            //int index = 0;

            foreach (Match m in optionMatch.OfType<Match>().OrderByDescending(x => x.Index))
            {
                Options.Add(m.Groups[1].Value, m.Groups[2].Value);

                optionsExpr = optionsExpr.Remove(m.Index, m.Length);
            }

            // not all parts were parameters
            if (optionsExpr != String.Empty)
            {
                throw new UriFormatException(UriString, new Exception("Invalid options: \"" + optionsExpr + "\""));
            }
        }