public void no_criteria_passed()
        {
            var search = new Search();
            var result = new QueryFactory().CreateQuery(search);

            Assert.AreEqual(string.Empty, result);
        }
        public void find_by_equality()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.And);
            search.AddSearchCriteria(SearchCombinator.Or)
                  .AddCriteria("Name", SearchCondition.Equals, "TestParty");
            var result = new QueryFactory().CreateQuery(search);

            Assert.AreEqual("(Name = \"TestParty\")", result);
        }
        public void find_by_lessthanequal()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.And);
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Balance", SearchCondition.LessThanEquals, "120", true);
            var result = new QueryFactory().CreateQuery(search);

            Assert.AreEqual("(Balance <= 120)", result);
        }
        public void find_by_numeric_equality()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.And);
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Balance", SearchCondition.NumericEquals, "120");
            var result = new QueryFactory().CreateQuery(search);

            Assert.AreEqual("(Balance = 120)", result);
        }
        public void case_sensitive_mapping()
        {
            var search = new Search();

            search.SearchOptions.IsMappingSearch = true;
            search.SearchOptions.CaseSensitivity = true;

            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("MappingValue", SearchCondition.Contains, "Test");
            var result = new QueryFactory().CreateQuery(search);

            Assert.AreEqual("(MappingValue.Contains(\"Test\"))", result);
        }
        public void find_party_with_two_search_criteria()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.Or);
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Name",  SearchCondition.Equals, "Test")
                  .AddCriteria("FaxNumber", SearchCondition.Contains, "01302");
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Name", SearchCondition.Equals, "Bob")
                  .AddCriteria("FaxNumber", SearchCondition.Contains, "01942");

            var result = new QueryFactory().CreateQuery(search);
            Assert.AreEqual("(Name = \"Test\" And FaxNumber.Contains(\"01302\")) Or (Name = \"Bob\" And FaxNumber.Contains(\"01942\"))", result);
        }
        public void find_party_by_two_wildcards_anded()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.And);
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Name", SearchCondition.Contains, "Test")
                  .AddCriteria("Name", SearchCondition.Contains, "Party");

            var result = new QueryFactory().CreateQuery(search);
            Assert.AreEqual("(Name.Contains(\"Test\") And Name.Contains(\"Party\"))", result);
        }
        public void find_party_by_name_and_faxnumber()
        {
            var search = SearchBuilder.CreateSearch(SearchCombinator.And);
            search.AddSearchCriteria(SearchCombinator.And)
                  .AddCriteria("Name", SearchCondition.Equals, "TestParty")
                  .AddCriteria("FaxNumber", SearchCondition.Equals, "01302555555");

            var result = new QueryFactory().CreateQuery(search);
            Assert.AreEqual("(Name = \"TestParty\" And FaxNumber = \"01302555555\")", result);
        }