public void SpatialFilterParameter004()
        {
            // Arrange
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new SpatialFilterParameter <TestDocument>(expressionBuilder);

            // Act / Assert
            Assert.Throws <ArgumentNullException>(() => parameter.Configure(null, SolrSpatialFunctionType.Bbox, new GeoCoordinate(), 10));
        }
        public void SpatialFilterParameter003()
        {
            // Arrange
            bool   actual;
            string dummy;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new SpatialFilterParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.NotIndexed, SolrSpatialFunctionType.Geofilt, new GeoCoordinate(), 0);

            // Act
            parameter.Validate(out actual, out dummy);

            // Assert
            Assert.False(actual);
        }
        public void SpatialFilterParameter006()
        {
            // Arrange
            bool   isValid;
            string errorMessage;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new SpatialFilterParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.Indexed, SolrSpatialFunctionType.Geofilt, new GeoCoordinate(), 0);

            // Act
            parameter.Validate(out isValid, out errorMessage);

            // Assert
            Assert.True(isValid);
        }
        public void SpatialFilterParameter002()
        {
            // Arrange
            var container         = new List <string>();
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new SpatialFilterParameter <TestDocument>(expressionBuilder);

            parameter.Configure(q => q.Spatial, SolrSpatialFunctionType.Bbox, new GeoCoordinate(-1.1M, -2.2M), 5.5M);

            // Act
            parameter.Execute(container);

            // Assert
            Assert.Equal(1, container.Count);
            Assert.Equal("fq={!bbox sfield=_spatial_ pt=-1.1,-2.2 d=5.5}", container[0]);
        }
        public void SpatialFilterParameter008()
        {
            // Arrange
            var container         = new List <string>();
            var expressionCache   = new ExpressionCache <TestDocument>();
            var expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var parameter         = new SpatialFilterParameter <TestDocument>(expressionBuilder);

            parameter.Configure(q => q.Spatial, SolrSpatialFunctionType.Geofilt, new GeoCoordinate(52.9127M, 4.7818799M), 1M);

            // Act
            parameter.Execute(container);

            // Assert
            Assert.Equal(1, container.Count);
            Assert.Equal("fq={!geofilt sfield=_spatial_ pt=52.9127,4.7818799 d=1}", container[0]);
        }
        public void SpatialFilterParameter007()
        {
            // Arrange
            bool   isValid;
            string errorMessage;
            var    expressionCache   = new ExpressionCache <TestDocumentWithAttribute>();
            var    expressionBuilder = (IExpressionBuilder <TestDocumentWithAttribute>) new ExpressionBuilder <TestDocumentWithAttribute>(expressionCache);
            var    parameter         = new SpatialFilterParameter <TestDocumentWithAttribute>(expressionBuilder);

            parameter.Configure(q => q.NotIndexed, SolrSpatialFunctionType.Geofilt, new GeoCoordinate(), 0);

            // Act
            parameter.Validate(out isValid, out errorMessage);

            // Assert
            Assert.False(isValid);
            Assert.Equal(Resource.FieldMustBeIndexedTrueToBeUsedInAQueryException, errorMessage);
        }
        public void SpatialFilterParameter002()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              params:{
                fq:""{!bbox sfield=_spatial_ pt=-1.1,-2.2 d=5.5}""
              }
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter         = new SpatialFilterParameter <TestDocument>(expressionBuilder);

            parameter.Configure(q => q.Spatial, SolrSpatialFunctionType.Bbox, new GeoCoordinate(-1.1M, -2.2M), 5.5M);

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

            // Assert
            Assert.Equal(expected.ToString(), actual);
        }
        public void SpatialFilterParameter008()
        {
            // Arrange
            var    expected = JObject.Parse(@"
            {
              params:{
                fq:""{!geofilt sfield=_spatial_ pt=52.9127,4.7818799 d=1}""
              }
            }");
            string actual;
            var    jObject           = new JObject();
            var    expressionCache   = new ExpressionCache <TestDocument>();
            var    expressionBuilder = (IExpressionBuilder <TestDocument>) new ExpressionBuilder <TestDocument>(expressionCache);
            var    parameter         = new SpatialFilterParameter <TestDocument>(expressionBuilder);

            parameter.Configure(q => q.Spatial, SolrSpatialFunctionType.Geofilt, new GeoCoordinate(52.9127M, 4.7818799M), 1M);

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

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