Ejemplo n.º 1
0
        public void FilterParameter001()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              ""filter"": [
                ""_id_:X"",
                ""_score_:Y""
              ]
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter1        = new FilterParameter <TestDocument>(expressionBuilder);
            var    parameter2        = new FilterParameter <TestDocument>(expressionBuilder);

            parameter1.Configure(new Single <TestDocument>(q => q.Id, "X"));
            parameter2.Configure(new Single <TestDocument>(q => q.Score, "Y"));

            // Act
            parameter1.Execute(jObject);
            parameter2.Execute(jObject);
            actual = jObject.ToString();

            // Assert
            Assert.Equal(expected.ToString(), actual);
        }
Ejemplo n.º 2
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]);
        }
Ejemplo n.º 3
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]);
        }
Ejemplo n.º 4
0
        public void FilterParameter003()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              ""filter"": [
                ""{!tag=tag1}_id_:X""
              ]
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter         = new FilterParameter <TestDocument>(expressionBuilder);

            parameter.Configure(new Single <TestDocument>(q => q.Id, "X"), "tag1");

            // Act
            parameter.Execute(jObject);
            actual = jObject.ToString();

            // Assert
            Assert.Equal(expected.ToString(), actual);
        }