예제 #1
0
        public async void SearchAsync_StatusCodeIsNotOK_ElasticException()
        {
            //arrange
            _searchResponseMock.SetupGet(x => x.ApiCall.HttpStatusCode)
            .Returns((int)HttpStatusCode.NoContent);

            var request = new QuestionElasticSearchRequest
            {
                Text = "test"
            };

            //act, assert
            await Assert.ThrowsAsync <ElasticException>(() =>
                                                        _client.SearchAsync <SearchableQuestion>(request,
                                                                                                 f => f.Match(mqd => mqd.Query("test text").Fuzziness(Fuzziness.Auto))));
        }
예제 #2
0
        public async void SearchAsync_CorrectParameters_ShouldCallElasticClientSearchAsync()
        {
            //arrange
            var request = new QuestionElasticSearchRequest
            {
                Text = "test"
            };

            _searchResponseMock.SetupGet(x => x.ApiCall.HttpStatusCode)
            .Returns((int)HttpStatusCode.OK);
            //act
            await _client.SearchAsync <SearchableQuestion>(request,
                                                           f => f.Match(mqd => mqd.Query("test text").Fuzziness(Fuzziness.Auto)));

            //assert
            _elasticClientWrapperMock.Verify(
                v => v.SearchAsync(
                    It.IsAny <Func <SearchDescriptor <SearchableQuestion>, ISearchRequest> >()), Times.Once);
        }