public TranslatorApiEnumerationRepository( EnumerationRepositoryConfiguration configuration, IRestClient restClient, ISpiExecutionContextManager executionContextManager, ICacheProvider cacheProvider, ILoggerWrapper logger) { _configuration = configuration; _restClient = restClient; _executionContextManager = executionContextManager; _cacheProvider = cacheProvider; _logger = logger; _restClient.BaseUrl = new Uri(configuration.TranslatorApiBaseUrl); if (!string.IsNullOrEmpty(configuration.TranslatorApiFunctionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.AzureFunctionKeyHeaderName, configuration.TranslatorApiFunctionKey, ParameterType.HttpHeader)); } if (!string.IsNullOrEmpty(configuration.TranslatorApiSubscriptionKey)) { _restClient.DefaultParameters.Add(new Parameter(CommonHeaderNames.EapimSubscriptionKeyHeaderName, configuration.TranslatorApiSubscriptionKey, ParameterType.HttpHeader)); } }
public void Arrange() { _configuration = new EnumerationRepositoryConfiguration { TranslatorApiBaseUrl = "https://translator.unit.tests", }; _restClientMock = new Mock <IRestClient>(); _restClientMock.Setup(c => c.ExecuteTaskAsync(It.IsAny <IRestRequest>(), It.IsAny <CancellationToken>())) .ReturnsAsync(new RestResponse { StatusCode = HttpStatusCode.OK, ResponseStatus = ResponseStatus.Completed, Content = JsonConvert.SerializeObject(new GetEnumerationValuesResult { EnumerationValuesResult = new EnumerationValuesResult { EnumerationValues = new string[0], }, }), }); _executionContextManager = new Mock <ISpiExecutionContextManager>(); _executionContextManager.Setup(m => m.SpiExecutionContext) .Returns(new SpiExecutionContext()); _cacheProviderMock = new Mock <ICacheProvider>(); _loggerMock = new Mock <ILoggerWrapper>(); _repository = new TranslatorApiEnumerationRepository( _configuration, _restClientMock.Object, _executionContextManager.Object, _cacheProviderMock.Object, _loggerMock.Object); _cancellationToken = new CancellationToken(); }