Beispiel #1
0
        public void RequestConstructor_ValidParams_Creates_NonNullInstance()
        {
            var options = new TmdbEasyOptions(_globalApiKey);

            var request = new Request(options);

            Assert.IsNotNull(request);
        }
Beispiel #2
0
        public void AddLanguage_DefaultLanguageSet_NoLocalLanguageUsed_SetsDefaultLanguage()
        {
            var options = new TmdbEasyOptions("apiKey", useSsl: true, _defaultLanguage);
            var request = new Request(options);

            request.AddLanguage();;

            Assert.IsTrue(request.GetUri().Contains($"?language={_defaultLanguage}"));
        }
Beispiel #3
0
        public void AddApiKey_GlobalApiKeySet_NoUserApiKeyProvided_SetsGlobalApiKey()
        {
            var options = new TmdbEasyOptions(_globalApiKey);
            var request = new Request(options);

            request.AddApiKey();

            Assert.IsTrue(request.GetUri().Contains($"?api_key={_globalApiKey}"));
        }
Beispiel #4
0
        public void AddApiKey_GlobalApiKeySet_UserApiKeyUsed_SetsUserApiKey()
        {
            var options = new TmdbEasyOptions(_globalApiKey);
            var request = new Request(options);

            string userApiKey = "userkey";

            request.AddApiKey(userApiKey);

            Assert.IsTrue(request.GetUri().Contains($"?api_key={userApiKey}"));
        }
Beispiel #5
0
        public TmdbEasyClient(TmdbEasyOptions options)
        {
            Options = options ?? throw new ArgumentNullException(nameof(options));

            _jsonDeserializer = options.JsonDeserializer;

            _httpClient = new HttpClient()
            {
                BaseAddress = new Uri(Options.UseSsl ? Constants.TmdbUrl3Ssl : Constants.TmdbUrl3)
            };
        }
Beispiel #6
0
 public Request(TmdbEasyOptions options)
 {
     _requestBuilder = new StringBuilder();
     _options        = options ?? throw new ArgumentNullException(nameof(options));
 }
Beispiel #7
0
 public RequestExtensionTests()
 {
     _defaultOptions = new TmdbEasyOptions(_globalApiKey);
 }
Beispiel #8
0
        public static IServiceCollection AddTmdbEasy(this IServiceCollection serviceCollection, TmdbEasyOptions options)
        {
            var sessionDescriptor = new ServiceDescriptor(
                typeof(ITmdbEasyClient), c =>
            {
                return(new TmdbEasyClient(options));
            }, ServiceLifetime.Singleton);

            serviceCollection.TryAdd(sessionDescriptor);

            serviceCollection.AddScoped <IReviewApi, ReviewApi>();
            serviceCollection.AddScoped <IChangesApi, ChangesApi>();
            serviceCollection.AddScoped <ICompaniesApi, CompaniesApi>();
            serviceCollection.AddScoped <ICollectionApi, CollectionApi>();
            serviceCollection.AddScoped <IConfigApi, ConfigApi>();
            serviceCollection.AddScoped <ICreditApi, CreditApi>();
            serviceCollection.AddScoped <IMovieApi, MovieApi>();
            serviceCollection.AddScoped <INetworksApi, NetworksApi>();
            serviceCollection.AddScoped <ITelevisionApi, TelevisionApi>();

            return(serviceCollection);
        }
        public void NullOptions_Throws_ArgumentNullException()
        {
            TmdbEasyOptions options = null;

            Assert.Throws <ArgumentNullException>(() => new TmdbEasyClient(options));
        }