/// <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,
                         IPlexMediaProvider mediaProvider)
 {
     Configuration = configuration
                     .ThrowIfNull(nameof(configuration))
                     .ThrowIfInvalid(nameof(configuration));
     _httpService = httpService
                    .ThrowIfNull(nameof(httpService));
     _authenticator = authenticator
                      .ThrowIfNull(nameof(authenticator));
     _serverSettingsProvider = serverSettingsProvider
                               .ThrowIfNull(nameof(serverSettingsProvider));
     _mediaProvider = mediaProvider
                      .ThrowIfNull(nameof(mediaProvider));
 }
Esempio n. 2
0
        public void Constructor_WithInvalidMediaProviderService_ShouldThrowArgumentNullException()
        {
            // Setup
            PlexMediaServerConfig config = new PlexMediaServerConfig
            {
                ServerAddress = "http://192.168.0.5:32400",
                PlexAuthenticationRequestUser = new BasicAuth
                {
                    Username = "******",
                    Password = "******"
                }
            };
            var httpService                  = Substitute.For <IHttpService>();
            var authenticator                = Substitute.For <IPlexAuthenticator>();;
            var settingsProvider             = Substitute.For <IPlexServerSettingsProvider>();
            IPlexMediaProvider mediaProvider = null;

            // Perform
            var exception = Assert.Throws <ArgumentNullException>(() =>
                                                                  new PlexMediaService(config, httpService, authenticator, settingsProvider, mediaProvider));

            // Assert
            Assert.Equal("mediaProvider", exception.ParamName);
        }