Exemple #1
0
        public void FilterQueryParameter001()
        {
            // Arrange
            var container         = new List <string>();
            var solrOptions       = new SolrExpressOptions();
            var solrConnection    = new FakeSolrConnection <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(solrOptions, solrConnection);

            expressionBuilder.LoadDocument();
            var parameter1 = new FilterParameter <TestDocument>();

            parameter1.Query = new SearchQuery <TestDocument>(expressionBuilder).Field(q => q.Id).AddValue("X");
            var parameter2 = new FilterParameter <TestDocument>();

            parameter2.Query = new SearchQuery <TestDocument>(expressionBuilder).Field(q => q.Score).AddValue("Y");

            // Act
            parameter1.Execute();
            parameter1.AddResultInContainer(container);
            parameter2.Execute();
            parameter2.AddResultInContainer(container);

            // Assert
            Assert.Equal(2, container.Count);
            Assert.Equal("fq=id:\"X\"", container[0]);
            Assert.Equal("fq=score:\"Y\"", container[1]);
        }
Exemple #2
0
        public void FilterQueryParameter002()
        {
            // Arrange
            var container         = new List <string>();
            var solrOptions       = new SolrExpressOptions();
            var solrConnection    = new FakeSolrConnection <TestDocument>();
            var expressionBuilder = new ExpressionBuilder <TestDocument>(solrOptions, solrConnection);

            expressionBuilder.LoadDocument();
            var searchQuery = new SearchQuery <TestDocument>(expressionBuilder);
            var parameter   = new FilterParameter <TestDocument>();

            parameter.Query   = searchQuery.Field(q => q.Id).AddValue("X");
            parameter.TagName = "tag1";

            // Act
            parameter.Execute();
            parameter.AddResultInContainer(container);

            // Assert
            Assert.Single(container);
            Assert.Equal("fq={!tag=tag1}id:\"X\"", container[0]);
        }