Beispiel #1
0
        public async void BadRequestThrowsException()
        {
            _httpHandler.Response = ResponseSamples.BadRequest("Failure!");

            await _cloudSearchClient.SearchAsync <Result>(new SearchRequest
            {
                Query = new SimpleQuery("123")
            });
        }
Beispiel #2
0
        public async void BadRequestsShouldNotBeRetried()
        {
            _httpHandler.Response = ResponseSamples.BadRequest();

            try
            {
                await _cloudSearchClient.SearchAsync <Result>(new SearchRequest
                {
                    Query = new SimpleQuery("123")
                });
            }
            catch (SearchException ex)
            {
                Assert.That(ex.ShouldRetry, Is.False);
            }
        }
        public async void BadRequestIncludesInfoInException()
        {
            _httpHandler.Response = ResponseSamples.BadRequest();

            try
            {
                await _cloudSearchClient.SearchAsync <Result>(new SearchRequest
                {
                    Query = new SimpleQuery("123")
                });
            }
            catch (SearchException ex)
            {
                Assert.That(ex.Request.Parser, Is.EqualTo("simple"));
                Assert.That(ex.Request.Query, Is.EqualTo("123"));
                Assert.That(ex.Request.Url, Is.EqualTo("search?q=123&q.parser=simple"));
            }
        }
Beispiel #4
0
        public async void BadRequestIncludesInfoInException()
        {
            _httpHandler.Response = ResponseSamples.BadRequest();

            try
            {
                await _cloudSearchClient.SearchAsync <Result>(new SearchRequest
                {
                    Query = new SimpleQuery("123")
                });
            }
            catch (SearchException ex)
            {
                Assert.That(ex.Request.Url, Is.EqualTo("search"));
                Assert.That(ex.Request.Parameters, Is.EqualTo(new Dictionary <string, string>
                {
                    { "q", "123" },
                    { "q.parser", "simple" }
                }));
            }
        }