public void AssertMatches(ParsedRequest requestObject, string regexKey, string expectedMatch, int expectedMatchCount) { string value = requestObject.ToString(); expectedMatch = Utilities_String.EscapeSpecialRegexCharacters(expectedMatch); List <KeyValuePair <string, object> > matches = requestObject.GetMatches(regexKey); Assert.AreEqual(expectedMatchCount, matches.Count, string.Format("Count for value of {0} in {1}", regexKey, value)); if (matches.Count <= 0) { return; } KeyValuePair <string, object> match = matches.First(); bool isNull = (expectedMatch == null); if (isNull) { Assert.IsNull(match.Value); } else { Assert.IsTrue(Regex.IsMatch(match.Value.ToString(), expectedMatch, RegexOptions.IgnoreCase), Utilities_Assertion.ToString(string.Format("Value of {0} in {1}", regexKey, value), expectedMatch, match.Value)); } System.Console.WriteLine(string.Format("HTTP_Request:\n\tType: {0}\tToString: {1}", requestObject.GetType(), requestObject.ToString())); }
public void Test_UpdateMatchingEntryId(string value, string regexKey, string expectedMatch, int expectedMatchCount) { if (expectedMatchCount != 1 || !regexKey.Equals(Constants.REGEX_WAS_ENTRY_IES)) { return; } expectedMatch = "-88888"; ParsedRequest requestObject = ParsedRequest.GetParsedRequest(value); List <KeyValuePair <string, object> > matches = requestObject.GetMatches(regexKey); foreach (KeyValuePair <string, object> match in matches) { requestObject.Update(match, expectedMatch, requestObject.Dictionary); } AssertMatches(requestObject, regexKey, expectedMatch, expectedMatchCount); }