public void Constructor_WithInvalidAuthHeaderConstructor_ShouldThrowArgumentNullException() { // Setup var config = new PlexMediaServerConfig { PlexAuthenticationRequestUser = new BasicAuth { Username = "******", Password = "******" }, ServerAddress = "http://192.168.0.5:32400" }; var httpService = Substitute.For <IHttpService>(); var plexBasicHeadersConstructor = Substitute.For <IHeaderConstructor <PlexBasicRequestHeaders> >(); IHeaderConstructor <BasicAuthRequest> basicAuthHeadersConstructor = null; // Perform action 'Constructor' var exception = Assert.Throws <ArgumentNullException>(() => { var instance = new PlexTvAuthenticator(httpService, plexBasicHeadersConstructor, basicAuthHeadersConstructor, config); }); // Assert that 'ShouldThrowArgumentNullException' = 'WithInvalidConfig' Assert.Equal("basicAuthHeadersConstructor", exception.ParamName); }
/// <summary> /// Overloaded constructor to pass configuration. /// </summary> /// <param name="httpService">Instance of static http service to use in making web requests.</param> /// <param name="plexBasicHeadersConstructor">Constructor for Plex headers.</param> /// <param name="configuration">Media server specific configuration.</param> public PlexServerPreferencesProviderService(IHttpService httpService, IHeaderConstructor <PlexBasicRequestHeaders> plexBasicHeadersConstructor, PlexMediaServerConfig configuration) { _configuration = configuration .ThrowIfNull(nameof(configuration)) .ThrowIfInvalid(nameof(configuration)); _httpService = httpService .ThrowIfNull(nameof(httpService)); _plexBasicHeaders = plexBasicHeadersConstructor .ThrowIfNull(nameof(plexBasicHeadersConstructor)) .ConstructRequestHeaders(configuration.BasicPlexHeaders); }
/// <summary> /// Overloaded constructor to pass configuration. /// </summary> /// <param name="httpService">Instance of static http service to use in making web requests.</param> /// <param name="plexBasicHeadersConstructor">Constructor for Plex headers.</param> /// <param name="basicAuthHeadersConstructor">Constructor for Plex headers.</param> /// <param name="configuration">Media server specific configuration.</param> public PlexTvAuthenticator(IHttpService httpService, IHeaderConstructor <PlexBasicRequestHeaders> plexBasicHeadersConstructor, IHeaderConstructor <BasicAuthRequest> basicAuthHeadersConstructor, PlexMediaServerConfig configuration) { _configuration = configuration .ThrowIfNull(nameof(configuration)) .ThrowIfInvalid(nameof(configuration)); _httpService = httpService .ThrowIfNull(nameof(httpService)); _plexBasicHeaders = plexBasicHeadersConstructor .ThrowIfNull(nameof(plexBasicHeadersConstructor)) .ConstructRequestHeaders(configuration.BasicPlexHeaders); _basicAuthConstructor = basicAuthHeadersConstructor .ThrowIfNull(nameof(basicAuthHeadersConstructor)); }
/// <summary> /// Overloaded constructor to pass configuration. /// </summary> /// <param name="configuration">Media server specific configuration.</param> /// <param name="httpService">Instance of static http service to use in making web requests.</param> /// <param name="authenticator">Instance of static http service to use in making web requests.</param> /// <param name="serverSettingsProvider">Instance of Plex server settings provider.</param> /// <param name="mediaProvider">Instance of Plex server media provider.</param> public PlexMediaService(PlexMediaServerConfig configuration, IHttpService httpService, IPlexAuthenticator authenticator, IPlexServerSettingsProvider serverSettingsProvider, IHeaderConstructor <PlexBasicRequestHeaders> plexBasicHeadersConstructor) { Configuration = configuration .ThrowIfNull(nameof(configuration)) .ThrowIfInvalid(nameof(configuration)); _httpService = httpService .ThrowIfNull(nameof(httpService)); _authenticator = authenticator .ThrowIfNull(nameof(authenticator)); _serverSettingsProvider = serverSettingsProvider .ThrowIfNull(nameof(serverSettingsProvider)); _plexBasicHeaders = plexBasicHeadersConstructor .ThrowIfNull(nameof(plexBasicHeadersConstructor)) .ConstructRequestHeaders(configuration.BasicPlexHeaders); }