public void Arrange() { _restClientMock = new Mock <IRestClient>(); _restClientMock.Setup(c => c.ExecuteTaskAsync(It.IsAny <RestRequest>(), _cancellationToken)) .ReturnsAsync(new RestResponse { Content = JsonConvert.SerializeObject(new EntityCollection <LearningProvider> { SquashedEntityResults = new SquashedEntityResult <LearningProvider> [0], }), StatusCode = HttpStatusCode.OK, ResponseStatus = ResponseStatus.Completed, }); _configuration = new EntityRepositoryConfiguration { SquasherApiBaseUrl = "https://search.example.com/" }; _executionContextManager = new Mock <ISpiExecutionContextManager>(); _executionContextManager.Setup(m => m.SpiExecutionContext) .Returns(new SpiExecutionContext()); _loggerMock = new Mock <ILoggerWrapper>(); _repository = new SquasherEntityRepository( _restClientMock.Object, _configuration, _executionContextManager.Object, _loggerMock.Object); _cancellationToken = new CancellationToken(); }
public SquasherEntityRepository( IRestClient restClient, EntityRepositoryConfiguration configuration, ISpiExecutionContextManager executionContextManager, ILoggerWrapper logger) { _restClient = restClient; _restClient.Timeout = 600 * 1000; // 600s - 10m _executionContextManager = executionContextManager; _restClient.BaseUrl = new Uri(configuration.SquasherApiBaseUrl, UriKind.Absolute); if (!string.IsNullOrEmpty(configuration.SquasherApiFunctionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.AzureFunctionKeyHeaderName, configuration.SquasherApiFunctionKey, ParameterType.HttpHeader)); } if (!string.IsNullOrEmpty(configuration.SquasherApiSubscriptionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.EapimSubscriptionKeyHeaderName, configuration.SquasherApiSubscriptionKey, ParameterType.HttpHeader)); } _logger = logger; }