public void Starts_with_criterion_query() { var criterion = Criterions.StartsWith("Ale"); var builder = new QueryBuilder(Criterions.Field<Person, string>(x => x.Name.Firstname, criterion)); AssertFoundNavalny(builder); }
public void String_any_with_ignore_case_query() { var criterion = Criterions.IgnoreCase(Criterions.Any("patriotic")); var builder = new QueryBuilder(Criterions.Field<Person, string[]>(x => x.Hobbies, criterion)); AssertFoundPutin(builder); }
public void String_any_query() { var criterion = Criterions.Any("Patriotic"); var builder = new QueryBuilder(Criterions.Field<Person, string[]>(x => x.Hobbies, criterion)); AssertFoundPutin(builder); }
public void Lower_than_query() { var criterion = Criterions.LowerThan(40); var builder = new QueryBuilder(Criterions.Field<Person, int>(x => x.Age, criterion)); AssertFoundNavalny(builder); }
public void String_ignore_case_query() { var criterion = Criterions.IgnoreCase(Criterions.Any("PUTIN")); var builder = new QueryBuilder(Criterions.Field<Person, string>(x => x.Name.Surname, criterion)); AssertFoundPutin(builder); }
public void In_criterion_query() { var criterion = Criterions.Field<Person, int>(x => x.Age, Criterions.In(36, 52)); var builder = new QueryBuilder(criterion); AssertFoundNavalny(builder); }
public void Between_query() { var criterion = Criterions.Between(30, 40); var builder = new QueryBuilder(Criterions.Field<Person, int>(x => x.Age, criterion)); AssertFoundNavalny(builder); }
public void Not_in_criterion_query() { var criterion = Criterions.Field<Person, int>(x => x.Age, Criterions.NotIn(36, 52)); var builder = new QueryBuilder(criterion); AssertFoundPutin(builder); }
public void Greater_than_query() { var criterion = Criterions.GreaterThan(40); var builder = new QueryBuilder(Criterions.Field<Person, int>(x => x.Age, criterion)); AssertFoundPutin(builder); }
public void Element_match_criterion_simple_array_query() { var criterion = Criterions.Field<Person, string[]>( x=> x.Hobbies, Criterions.MatchElement( Criterions.Equals("Power"))); var builder = new QueryBuilder(criterion); AssertFoundPutin(builder); }
public void And_criterion_query() { var byName = Criterions.Field<Person, string>(x => x.Name.Firstname, Criterions.Equals("Alexey")); var byAge = Criterions.Field<Person, int>(x => x.Age, Criterions.Equals(36)); var andCritertion = Criterions.And(byName, byAge); var builder = new QueryBuilder(andCritertion); AssertFoundNavalny(builder); }
protected void AssertFoundBoth(QueryBuilder builder) { using (var query = Collection.CreateQuery<Person>(builder)) using (var cursor = query.Execute(QueryMode.Explain)) { Console.WriteLine(builder.ToString()); Console.WriteLine(cursor.GetLog()); Assert.That(cursor.Count, Is.EqualTo(2)); } }
public void Exists_criterion_query() { var criterion = Criterions.FieldExists(); var builder = new QueryBuilder(Criterions.Field<Person, string>(x => x.Name.Firstname, criterion)); using (var query = Collection.CreateQuery<Person>(builder)) using (var cursor = query.Execute(QueryMode.Explain)) { Console.WriteLine(cursor.GetLog()); Assert.That(cursor.Count, Is.EqualTo(2)); } }
public void Element_match_criterion_complex_property_query() { var criterion = Criterions.Field<Person, Name>( x => x.Name, Criterions.MatchElement( Criterions.Object( Criterions.Field<Name, string>(x => x.Firstname, Criterions.Equals("Vladimir")), Criterions.Field<Name, string>(x => x.Surname, Criterions.Equals("Putin"))) )); var builder = new QueryBuilder(criterion); AssertFoundPutin(builder); }
protected void AssertFoundNavalny(QueryBuilder builder) { using (var query = Collection.CreateQuery<Person>(builder)) using (var cursor = query.Execute(QueryMode.Explain)) { Console.WriteLine(builder.ToString()); Console.WriteLine(cursor.GetLog()); var person = cursor[0]; Assert.That(cursor.Count, Is.EqualTo(1)); Assert.That(person.Name.Surname, Is.EqualTo(Person.Navalny().Name.Surname)); } }
public void Complex_criterion_combination_query() { var byName = Criterions.Field<Person, string>(x => x.Name.Firstname, Criterions.Equals("Alexey")); var byAge = Criterions.Field<Person, int>(x => x.Age, Criterions.Equals(36)); var andCriterion = Criterions.And(byName, byAge); var ignoreCaseHobby = Criterions.IgnoreCase(Criterions.Any("corruption")); var byHobbies = Criterions.Field<Person, string[]>(x => x.Hobbies, ignoreCaseHobby); var criterion = Criterions.Or(andCriterion, byHobbies); var builder = new QueryBuilder(criterion); AssertFoundBoth(builder); }
public void Match_criterion_query() { var criterion = Criterions.Equals("Alexey"); var builder = new QueryBuilder(Criterions.Field<Person, string>(x => x.Name.Firstname, criterion)); AssertFoundNavalny(builder); }
public void Or_criterion_query() { var byName = Criterions.Field<Person, string>(x => x.Name.Firstname, Criterions.Equals("Alexey")); var byAge = Criterions.Field<Person, int>(x => x.Age, Criterions.Equals(61)); var criterion = Criterions.Or(byName, byAge); var builder = new QueryBuilder(criterion); AssertFoundBoth(builder); }
public void Negate_criterion_query() { var criterion = Criterions.Not(Criterions.Equals("Alexey")); var builder = new QueryBuilder(Criterions.Field<Person, string>(x => x.Name.Firstname, criterion)); AssertFoundPutin(builder); }