Пример #1
0
 public GoodreadsService(HttpClient httpClient, IOptions <GoodreadsSettings> settings)
 {
     _httpClient = httpClient;
     _settings   = settings.Value;
     if (string.IsNullOrWhiteSpace(_settings.ApiKey))
     {
         throw new Exception("Api key cannot be null or white spaces");
     }
 }
Пример #2
0
 public void InitializeClass()
 {
     _httpMessageHandlerMock = new Mock <HttpMessageHandler>();
     _goodreadsSettings      = new GoodreadsSettings();
     _baseUrl       = "https://www.goodreads.com";
     _validApiKey   = "Valid Api";
     _invalidApiKey = "Invalid Api";
     _httpClient    = new HttpClient(_httpMessageHandlerMock.Object)
     {
         BaseAddress = new Uri(_baseUrl)
     };
     _goodreadsSettings = new GoodreadsSettings {
         ApiKey = _validApiKey
     };
     _service = new GoodreadsServiceProxy(
         _httpClient,
         new OptionsWrapper <GoodreadsSettings>(_goodreadsSettings));
 }