/// <summary> /// Initializes a new instance of the class with an <see cref="ITikkieConfiguration"/> as parameter. /// </summary> /// <param name="configuration">The Tikkie API configuration</param> /// <exception cref="ArgumentNullException">If the parameter is null</exception> public AuthorizedRequestsHandler(ITikkieConfiguration configuration) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _authenticationRequestsHandler = new AuthenticationRequestsHandler(_configuration); AuthorizationTokenInfo = _authenticationRequestsHandler.AuthorizationTokenInfo; _httpClientFactory = () => new HttpClient(); }
/// <summary> /// Internal constructor used for unit tests. /// Initializes a new instance of the class with an <see cref="ITikkieConfiguration"/>, <see cref="IAuthenticationRequestsHandler"/> /// and a factory of <see cref="HttpClient"/> as parameters. /// </summary> /// <param name="configuration">The Tikkie API configuration</param> /// <param name="authenticationRequestsHandler">The authentication requests handler</param> /// <param name="httpClientFactory">Factory to inject the HttpClient</param> /// <exception cref="ArgumentNullException">If any of the parameters are null</exception> internal AuthorizedRequestsHandler( ITikkieConfiguration configuration, IAuthenticationRequestsHandler authenticationRequestsHandler, Func <HttpClient> httpClientFactory) { _configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); _authenticationRequestsHandler = authenticationRequestsHandler ?? throw new ArgumentNullException(nameof(authenticationRequestsHandler)); _httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); }
private AuthorizedRequestsHandler CreateSut(ITikkieConfiguration configuration, IAuthenticationRequestsHandler authenticationRequestsHandler, Func <HttpClient> httpClientFactory) => new AuthorizedRequestsHandler(configuration, authenticationRequestsHandler, httpClientFactory);