public static void validate_cleanuri_keeps_conventional_port_443() { var uri = new Uri("http://www.example.com:443/dir/?query=test"); var result = StringsHelper.CleanUri(uri); Assert.AreEqual("http://www.example.com:443/dir/", result); }
public static void validate_cleanuri_returns_original_uri_for_relative_uris_and_strips_querystring() { Uri uri = new Uri("/relative/uri?dude=666", UriKind.Relative); var result = StringsHelper.CleanUri(uri); Assert.AreEqual("/relative/uri", result); }
public static void validate_cleanuri_is_stringempty_when_uri_is_null() { Uri uri = null; var result = StringsHelper.CleanUri(uri); Assert.AreEqual(string.Empty, result); }
public static void validate_cleanuri_leaves_unconventional_ports_removes_querystring() { var uri = new Uri("http://www.example.com:8080/dir/?query=test"); var result = StringsHelper.CleanUri(uri); Assert.AreEqual("http://www.example.com:8080/dir/", result); }
public virtual ParsedSqlStatement ParseStatement(DatastoreVendor vendor, CommandType commandType, string commandText, string statement) { if (!string.IsNullOrEmpty(_shortcut) && !statement.StartsWith(_shortcut, StringComparison.CurrentCultureIgnoreCase)) { return(null); } var matcher = _pattern.Match(statement); if (!matcher.Success) { return(null); } var model = "unknown"; foreach (Group g in matcher.Groups) { var str = g.ToString(); if (!string.IsNullOrEmpty(str)) { model = str; } } if (string.Equals(model, "select", StringComparison.CurrentCultureIgnoreCase)) { model = "(subquery)"; } else { model = StringsHelper.FixDatabaseObjectName(model); if (!IsValidModelName(model)) { model = "ParseError"; } } return(CreateParsedDatabaseStatement(vendor, model)); }
/// <summary> /// Heursitical crawl through a database command to find features suitable for making metric names. /// This uses linear search through the regexp patterns. /// </summary> /// <returns>A ParsedDatabaseStatement if some heuristic matches; otherwise null</returns> public static ParsedSqlStatement GetParsedDatabaseStatement(DatastoreVendor datastoreVendor, CommandType commandType, string commandText) { try { switch (commandType) { case CommandType.TableDirect: return(new ParsedSqlStatement(datastoreVendor, commandText, "select")); case CommandType.StoredProcedure: return(new ParsedSqlStatement(datastoreVendor, StringsHelper.FixDatabaseObjectName(commandText), "ExecuteProcedure")); } // Remove comments. var statement = CommentPattern.Replace(commandText, string.Empty).TrimStart(); return(_statementParser(datastoreVendor, commandType, commandText, statement)); } catch { return(new ParsedSqlStatement(datastoreVendor, null, null)); } }
public static void TestUnquoteTick() { Assert.AreEqual("dude", StringsHelper.FixDatabaseObjectName("`dude`")); }
public static void TestUnquoteSingle() { Assert.AreEqual("dude", StringsHelper.FixDatabaseObjectName("'dude'")); }
public static void TestUnquoteDouble() { Assert.AreEqual("dude", StringsHelper.FixDatabaseObjectName("\"dude\"")); }
public static void TestFixDatabaseObjectNameWithBrackets() { Assert.AreEqual("dude", StringsHelper.FixDatabaseObjectName("[dude]")); }
public void validate_CleanUri_String_Version(string uri, string expected) { var actual = StringsHelper.CleanUri(uri); Assert.AreEqual(expected, actual); }
public void DoubleBracket() { Assert.AreEqual("dude", StringsHelper.RemoveBracketsQuotesParenthesis("[[dude]]")); }