Пример #1
0
        public void GetProviderShouldLogWhenInvalidStatusCode()
        {
            var searchResponse = new Mock <ISearchResponse <ProviderDocument> >();
            var apiCall        = new Mock <IApiCallDetails>();

            apiCall.SetupGet(x => x.HttpStatusCode).Returns((int)HttpStatusCode.Ambiguous);
            searchResponse.SetupGet(x => x.ApiCall).Returns(apiCall.Object);

            var countResponse = new Mock <ICountResponse>();

            countResponse.SetupGet(x => x.Count).Returns(1);

            _elasticClient.Setup(x => x.Search(It.IsAny <Func <SearchDescriptor <ProviderDocument>, ISearchRequest> >(), It.IsAny <string>())).Returns(searchResponse.Object);
            var repo = new ProviderRepository(
                _elasticClient.Object,
                Mock.Of <IConfigurationSettings>(),
                _log.Object);

            _elasticClient.Setup(x => x.Count(It.IsAny <Func <CountDescriptor <Provider>, ICountRequest> >(), It.IsAny <string>())).Returns(countResponse.Object);

            Assert.Throws <ApplicationException>(() => repo.GetProvider(123));
        }