public void test_query_write_with_querybuilder() { var query = new StringQuery("Name", "智慧市政", OccurType.Should); var results = _provider.Query <DocumentSearchResult>(query); Assert.IsTrue(results.Count >= 3); }
public void should_construct_builder() { var query = new StringQuery("Name", "文档", OccurType.Should) .Next(new RangeQuery("UpdateTime", "2015-10-11", "2015-2-1", OccurType.Must)) .Next(new StringQuery("Content", "文档", OccurType.Should)); var rule = query.GetRule(); }
public void test_query_write_with_querybuilder_with_documentType() { var query = new StringQuery("Name", "智慧市政", OccurType.Should); query.Next(new StringQuery("DocumentType", DocumentType.Folder.ToString(), OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(query); Assert.AreEqual(results.Count, 1); }
public void test_write_documents_with_query_condition_with_range_begin_end_start_startIndex() { var query = new StringQuery("Name", "智慧市政", OccurType.Should); query.Next(new RangeQuery("UpdateTime", "20140721", "20141221", OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(query, 0, 1); Assert.AreEqual(results.Count, 1); }
public void test_write_documents_with_emptyString_condition_with_null_range_begin_end() { var query = new StringQuery("Name", "智慧市政", OccurType.Should); query.Next(new RangeQuery(string.Empty, " ", string.Empty, OccurType.Should)); var results = _provider.Query <DocumentSearchResult>(query); Assert.AreEqual(results.Count, 3); }
public void test_write_documents_with_query_and_fields() { var query = new StringQuery("Name", "报价明细表", OccurType.Should); query.Next(new StringQuery("DocumentType", DocumentType.Excel.ToString(), OccurType.Should)); var results = _provider.Query <DocumentSearchResult>(query); Assert.AreEqual(results.Count, 1); }
public void test_write_spaces_with_keyword_with_range_begin_end() { var query = new StringQuery("Name", "智慧市政", OccurType.Should); query.Next(new StringQuery("DocumentType", DocumentType.Folder.ToString(), OccurType.Must)) .Next(new RangeQuery("UpdateTime", "20140721", "20141221", OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(query); Assert.AreEqual(results.Count, 1); }
public void Export_ReturnsValidJson() { var query = new StringQuery("description:water and some other stuff"); var expected = JsonConvert.SerializeObject(new { query = "description:water and some other stuff" }, Formatting.None); Assert.AreEqual(expected, query.Export().ToString(Formatting.None)); }
public void test_write_documents_with_query_condition_with_different_documentType() { WriteSpace("spaces"); var query = new StringQuery("Name", "空间", OccurType.Should); query.Next(new StringQuery("DocumentType", DocumentType.Word.ToString(), OccurType.Must)); var results = _provider.Query <SearchResult>(query); Assert.AreEqual(results.Count, 0); }
public void test_write_spaces_with_keyword_with_must_occurType() { WriteSpace("spaces"); var query = new StringQuery("Name", "空间"); query.Next(new StringQuery("Content", "空间", OccurType.Must)); var results = _provider.Query <SearchResult>(query); Assert.AreEqual(results.Count, 0); }
public void test_query_write_with_querybuilder_with_documentType_with_unknowName() { var query = new StringQuery("Name", "unknowNamemyff"); var query2 = new StringQuery("Content", "unknowNamemyff"); var orQuery = new OrQuery(query, query2, OccurType.Must); orQuery.Next(new StringQuery("DocumentType", DocumentType.Excel.ToString(), OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(orQuery); Assert.AreEqual(results.Count, 0); }
public void test_write_documents_with_query_condition_with_different_documentType() { var query = new StringQuery("Name", "报价明细表", OccurType.Should); var query2 = new StringQuery("Content", "报价明细表", OccurType.Should); var orQuery = new OrQuery(query, query2, OccurType.Must); orQuery.Next(new StringQuery("DocumentType", DocumentType.Word.ToString(), OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(orQuery); Assert.AreEqual(results.Count, 0); }
public void test_write_documents_with_query_condition_with_range_begin_end() { WriteSpace("spaces"); var query = new StringQuery("Name", "空间", OccurType.Should); query.Next(new RangeQuery("UpdateTime", "20140521", "20140622", OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(query, 0, 1); Assert.AreEqual(results.Count, 1); }
public void test_write_documents_with_query_and_fields() { WriteSpace("spaces"); var query = new StringQuery("Name", "空间", OccurType.Should); query.Next(new StringQuery("DocumentType", DocumentType.Folder.ToString(), OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(query); Assert.AreEqual(results.Count, 2); }
public void test_write_documents_with_query_condition_with_all_query_empty() { var query = new StringQuery(string.Empty, string.Empty, OccurType.Should); var query2 = new StringQuery(string.Empty, string.Empty, OccurType.Should); var orQuery = new OrQuery(query, query2, OccurType.Must); orQuery.Next(new StringQuery(string.Empty, string.Empty, OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(orQuery); Assert.AreEqual(results.Count, 0); }
public void test_write_documents_with_query_condition_with_correct_name() { WriteSpace("spaces"); var query = new StringQuery("Name", "空间", OccurType.Should); var query2 = new StringQuery("Content", "空间", OccurType.Should); var orQuery = new OrQuery(query, query2, OccurType.Must); orQuery.Next(new StringQuery("DocumentType", DocumentType.Folder.ToString(), OccurType.Must)); var results = _provider.Query <DocumentSearchResult>(orQuery); Assert.AreEqual(results.Count, 2); }
static void Main(string[] args) { QueryExecutor queryExecutioner = new QueryExecutor(); IntQuery intQuery = new IntQuery(); StringQuery strQuery = new StringQuery(); CarQuery carQuery = new CarQuery(); Console.WriteLine(queryExecutioner.Execute(intQuery)); Console.WriteLine(queryExecutioner.Execute(strQuery)); Console.WriteLine(queryExecutioner.Execute(carQuery)); Console.ReadLine(); }
public void AddStringQuery(StringQuery sq) { if (m_StringQueries == null) { return; } if (m_StringQueries.Count >= m_StringQueryCap) { Console.WriteLine("Client: {0}: Exceeded string query cap, disconnecting...", this); Dispose(); } else { m_StringQueries.Add(sq); } }
public void ApplyConditions(IList <string> conditions, IList <string> values) { _queries = new List <IQuery>(); for (int i = 0; i < conditions.Count; i++) { if (conditions[i] == "") { _queries.Add(new EmptyQuery()); continue; } var field = _fields[i]; var value = values[i]; // create query based on type var q = new StringQuery(); q.ApplyFilter(field, conditions[i], value); _queries.Add(q); } }
public void Boost_ReturnsStringQuery() { var query = new StringQuery("description:water and some other stuff").Boost(2.2); Assert.IsInstanceOf <StringQuery> (query); }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Node to receive child</param> /// <param name="stringQueryOptions">Bitfield defining which string search types can be selected</param> /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param> public QueryStringPropertyInput(QueryNode parentNode, StringQuery stringQueryOptions, bool isReplacePattern) : base(parentNode, stringQueryOptions) { m_isReplacePattern = isReplacePattern; }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Parent node to receive child</param> /// <param name="stringQueryOptions">Bitfield defining which string search types can be selected</param> /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param> public QueryDomNodeName(QueryNode parentNode, StringQuery stringQueryOptions, bool isReplacePattern) : base(parentNode, stringQueryOptions, isReplacePattern) { }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Node to receive child</param> /// <param name="stringQueryOptions">Bitfield defining which string search types can be selected</param> /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param> public QueryPropertyValueAsStringInput(QueryNode parentNode, StringQuery stringQueryOptions, bool isReplacePattern) : base(parentNode, stringQueryOptions, isReplacePattern) { }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Node to receive child</param> /// <param name="stringQueryOptions">Bitfield defining which string search types can be selected</param> /// <param name="isReplacePattern">Whether or not this match should be used in a subsequent replace operation</param> public QueryDomNodeName(QueryNode parentNode, StringQuery stringQueryOptions, bool isReplacePattern) : base(parentNode, stringQueryOptions, isReplacePattern) { }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Parent QueryNode</param> /// <param name="stringQueryOptions">String search types</param> public QueryStringInput(QueryNode parentNode, StringQuery stringQueryOptions) { m_textInput = null; parentNode.Add(this); // get root node QueryNode nodeAbove = parentNode; while (nodeAbove.Parent != null) { nodeAbove = nodeAbove.Parent as QueryNode; } // register 'option changed' event to root node QueryRoot rootNode = nodeAbove as QueryRoot; if (rootNode != null) { rootNode.RegisterQueryOption(this); } if (stringQueryOptions != StringQuery.None) { QueryOptionItem newOptionItem; // "regular expression" if ((stringQueryOptions & StringQuery.RegularExpression) != 0) { newOptionItem = this.AddOptionItem("matches the regular expression", (UInt64)StringQuery.RegularExpression); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "contains" if ((stringQueryOptions & StringQuery.Contains) != 0) { newOptionItem = this.AddOptionItem("contains", (UInt64)StringQuery.Contains); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "matches" if ((stringQueryOptions & StringQuery.Matches) != 0) { newOptionItem = this.AddOptionItem("is", (UInt64)StringQuery.Matches); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "begins with" if ((stringQueryOptions & StringQuery.BeginsWith) != 0) { newOptionItem = this.AddOptionItem("begins with", (UInt64)StringQuery.BeginsWith); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "ends with" if ((stringQueryOptions & StringQuery.EndsWith) != 0) { newOptionItem = this.AddOptionItem("ends with", (UInt64)StringQuery.EndsWith); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } } }
/// <summary> /// Constructor</summary> /// <param name="parentNode">Parent QueryNode</param> /// <param name="stringQueryOptions">String search types</param> public QueryStringInput(QueryNode parentNode, StringQuery stringQueryOptions) { m_textInput = null; parentNode.Add(this); // get root node QueryNode nodeAbove = parentNode; while (nodeAbove.Parent != null) nodeAbove = nodeAbove.Parent as QueryNode; // register 'option changed' event to root node QueryRoot rootNode = nodeAbove as QueryRoot; if (rootNode != null) rootNode.RegisterQueryOption(this); if (stringQueryOptions != StringQuery.None) { QueryOptionItem newOptionItem; // "regular expression" if ((stringQueryOptions & StringQuery.RegularExpression) != 0) { newOptionItem = this.AddOptionItem("matches the regular expression", (UInt64)StringQuery.RegularExpression); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "contains" if ((stringQueryOptions & StringQuery.Contains) != 0) { newOptionItem = this.AddOptionItem("contains", (UInt64)StringQuery.Contains); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "matches" if ((stringQueryOptions & StringQuery.Matches) != 0) { newOptionItem = this.AddOptionItem("is", (UInt64)StringQuery.Matches); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "begins with" if ((stringQueryOptions & StringQuery.BeginsWith) != 0) { newOptionItem = this.AddOptionItem("begins with", (UInt64)StringQuery.BeginsWith); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } // "ends with" if ((stringQueryOptions & StringQuery.EndsWith) != 0) { newOptionItem = this.AddOptionItem("ends with", (UInt64)StringQuery.EndsWith); m_textInput = newOptionItem.AddStringSearchTextInput(m_textInput); } } }
private void RegisterMacro_Click(object sender, RoutedEventArgs e) { if (m_MacroList.SelectedItem != null) { if (m_MacroList.SelectedItem is ObjectBuilder) { App app = (App)App.Current; //app.registerMacroInScript(m_MacroList.SelectedItem as ObjectBuilder); ObjectBuilder obj = m_MacroList.SelectedItem as ObjectBuilder; if (obj != null) { StringQueryItem qry = new StringQueryItem("Enter macro name", "Macro Registration", "Macro"); StringQuery q = new StringQuery(); q.DataContext = qry; bool? result = q.ShowDialog(); if (result.Value) { if (result.Value) { Main.MessageHandler.registerMacro(qry.Text, obj); } } } sortMacros(); } } }
public void MultipleCharWithColonAsArgumentTest() { var stringQuery = new StringQuery(new[] { "/aa:" }); Assert.AreEqual(Helpers.ErrorMessage, stringQuery.ExecuteQuery()); }
public void PrintHelpTest() { var stringQuery = new StringQuery(new[] { "/?" }); Assert.AreEqual(Helpers.HelpMessage, stringQuery.ExecuteQuery()); }
public void UnknownArgumentTest() { var stringQuery = new StringQuery(new[] { "/z" }); Assert.AreEqual(Helpers.ErrorMessage, stringQuery.ExecuteQuery()); }
private void BtnRenameProfile_Click(object sender, EventArgs e) { if (this.ProfileListBox.SelectedItem == null) { return; } Profile profile = this.ProfileListBox.SelectedItem as Profile; StringQuery stringQuery = new StringQuery("Rename Profile", "Enter the new profile name:"); if (stringQuery.ShowDialog() == DialogResult.OK) { string text = Path.Combine(Profile.ProfileFolder, Path.GetFileNameWithoutExtension(profile.ProfileName) + ".settings"); profile.ProfileName = stringQuery.string_0; profile.SaveToFile(); string destFileName = Path.Combine(Profile.ProfileFolder, Path.GetFileNameWithoutExtension(stringQuery.string_0) + ".settings"); if (File.Exists(text)) { File.Move(text, destFileName); } this.method_1(); } }
public void Boost_WhenBoostIsLessThanZero_ThrowsArgumentOutOfRangeException() { var query = new StringQuery("description:water and some other stuff"); Assert.Throws <ArgumentOutOfRangeException>(() => query.Boost(-.1)); }
public void NullAsArgumentTest() { var stringQuery = new StringQuery(null); Assert.AreEqual(Helpers.HelpMessage, stringQuery.ExecuteQuery()); }