public void CreateQueryThrowsArgumentOutOfRangeIfExpressionTypeNotAssignableFromIQueryable()
        {
            var provider = new ElasticQueryProvider(connection, mapping, log, retryPolicy);

            Assert.Throws <ArgumentOutOfRangeException>(
                () => provider.CreateQuery <Sample>(Expression.Constant(new Sample())));
        }
        public void CreateQueryReturnsElasticQueryWithProviderSet()
        {
            var provider = new ElasticQueryProvider(connection, mapping, log, retryPolicy, "prefix");

            var query = provider.CreateQuery(validExpression);

            Assert.IsType<ElasticQuery<Sample>>(query);
            Assert.Same(provider, query.Provider);
        }
        public void CreateQueryReturnsElasticQueryWithProviderSet()
        {
            var provider = new ElasticQueryProvider(connection, mapping, log, retryPolicy);

            var query = provider.CreateQuery(validExpression);

            Assert.IsType <ElasticQuery <Sample> >(query);
            Assert.Same(provider, query.Provider);
        }
Example #4
0
        public void ConstantFalseDoesNotCauseConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy);
                var query    = new ElasticQuery <Robot>(provider).Where(f => false);

                ((IEnumerable)query).GetEnumerator();

                Assert.Empty(httpStub.Requests);
            }
        }
        public void ProviderExecuteTCausesPostToConnectionEndpoint()
        {
            using (var httpStub = new HttpStub(ZeroHits))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query = new ElasticQuery<Robot>(provider);

                provider.Execute<IEnumerable<Robot>>(query.Expression);

                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/robots/_search", request.RawUrl);
            }
        }
        public void ProviderExecuteTCausesPostToConnectionEndpoint()
        {
            using (var httpStub = new HttpStub(ZeroHits))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query    = new ElasticQuery <Robot>(provider);

                provider.Execute <IEnumerable <Robot> >(query.Expression);

                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/robots/_search", request.RawUrl);
            }
        }
Example #7
0
        public async void ProviderExecuteCausesPostToConnectionEndpoint()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy);
                var query    = new ElasticQuery <Robot>(provider);

                provider.Execute(query.Expression);

                await httpStub.Completion;
                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/_all/robots/_search", request.RawUrl);
            }
        }
        public void QueryImplicitGetEnumeratorCausesConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query    = new ElasticQuery <Robot>(provider);

                var enumerator = query.GetEnumerator();

                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/robots/_search", request.RawUrl);
                Assert.NotNull(enumerator);
            }
        }
        public async void ProviderExecuteCausesPostToConnectionEndpoint()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy);
                var query = new ElasticQuery<Robot>(provider);

                provider.Execute(query.Expression);

                await httpStub.Completion;
                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/_all/robots/_search", request.RawUrl);
            }
        }
Example #10
0
        public async void QueryExplicitIEnumerableGetEnumeratorCausesConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy);
                var query    = new ElasticQuery <Robot>(provider);

                var enumerator = ((IEnumerable)query).GetEnumerator();

                await httpStub.Completion;
                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/_all/robots/_search", request.RawUrl);
                Assert.NotNull(enumerator);
            }
        }
        public void QueryImplicitGetEnumeratorCausesConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query = new ElasticQuery<Robot>(provider);

                var enumerator = query.GetEnumerator();

                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/robots/_search", request.RawUrl);
                Assert.NotNull(enumerator);
            }
        }
        public void CreateQueryThrowsArgumentOutOfRangeIfExpressionTypeNotAssignableFromIQueryable()
        {
            var provider = new ElasticQueryProvider(connection, mapping, log, retryPolicy, "prefix");

            Assert.Throws<ArgumentOutOfRangeException>(() => provider.CreateQuery<Sample>(Expression.Constant(new Sample())));
        }
        public void ConstantFalseDoesNotCauseConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query = new ElasticQuery<Robot>(provider).Where(f => false);

                ((IEnumerable)query).GetEnumerator();

                Assert.Empty(httpStub.Requests);
            }
        }
        public async void QueryExplicitIEnumerableGetEnumeratorCausesConnection()
        {
            using (var httpStub = new HttpStub(ZeroHits, 1))
            {
                var provider = new ElasticQueryProvider(new ElasticConnection(httpStub.Uri), mapping, log, retryPolicy, "prefix");
                var query = new ElasticQuery<Robot>(provider);

                var enumerator = ((IEnumerable)query).GetEnumerator();

                await httpStub.Completion;
                var request = httpStub.Requests.Single();
                Assert.Equal("POST", request.HttpMethod);
                Assert.Equal("/_all/robots/_search", request.RawUrl);
                Assert.NotNull(enumerator);
            }
        }