mirror of
				https://github.com/jellyfin/jellyfin.git
				synced 2025-11-04 03:27:21 -05:00 
			
		
		
		
	Merge pull request #5339 from Bond-009/hasproviderids
Revert breaking change to HasProviderId
This commit is contained in:
		
						commit
						e858e5f0b8
					
				@ -9,6 +9,33 @@ namespace MediaBrowser.Model.Entities
 | 
			
		||||
    /// </summary>
 | 
			
		||||
    public static class ProviderIdsExtensions
 | 
			
		||||
    {
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Checks if this instance has an id for the given provider.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="instance">The instance.</param>
 | 
			
		||||
        /// <param name="name">The of the provider name.</param>
 | 
			
		||||
        /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns>
 | 
			
		||||
        public static bool HasProviderId(this IHasProviderIds instance, string name)
 | 
			
		||||
        {
 | 
			
		||||
            if (instance == null)
 | 
			
		||||
            {
 | 
			
		||||
                throw new ArgumentNullException(nameof(instance));
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return instance.ProviderIds?.ContainsKey(name) ?? false;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Checks if this instance has an id for the given provider.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
        /// <param name="instance">The instance.</param>
 | 
			
		||||
        /// <param name="provider">The provider.</param>
 | 
			
		||||
        /// <returns><c>true</c> if a provider id with the given name was found; otherwise <c>false</c>.</returns>
 | 
			
		||||
        public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider)
 | 
			
		||||
        {
 | 
			
		||||
            return instance.HasProviderId(provider.ToString());
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
        /// Gets a provider id.
 | 
			
		||||
        /// </summary>
 | 
			
		||||
 | 
			
		||||
@ -9,6 +9,44 @@ namespace Jellyfin.Model.Tests.Entities
 | 
			
		||||
    {
 | 
			
		||||
        private const string ExampleImdbId = "tt0113375";
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void HasProviderId_NullInstance_ThrowsArgumentNullException()
 | 
			
		||||
        {
 | 
			
		||||
            Assert.Throws<ArgumentNullException>(() => ProviderIdsExtensions.HasProviderId(null!, MetadataProvider.Imdb));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void HasProviderId_NullProvider_False()
 | 
			
		||||
        {
 | 
			
		||||
            var nullProvider = new ProviderIdsExtensionsTestsObject()
 | 
			
		||||
            {
 | 
			
		||||
                ProviderIds = null!
 | 
			
		||||
            };
 | 
			
		||||
 | 
			
		||||
            Assert.False(nullProvider.HasProviderId(MetadataProvider.Imdb));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void HasProviderId_NullName_ThrowsArgumentNullException()
 | 
			
		||||
        {
 | 
			
		||||
            Assert.Throws<ArgumentNullException>(() => ProviderIdsExtensionsTestsObject.Empty.HasProviderId(null!));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void HasProviderId_NotFoundName_False()
 | 
			
		||||
        {
 | 
			
		||||
            Assert.False(ProviderIdsExtensionsTestsObject.Empty.HasProviderId(MetadataProvider.Imdb));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void HasProviderId_FoundName_True()
 | 
			
		||||
        {
 | 
			
		||||
            var provider = new ProviderIdsExtensionsTestsObject();
 | 
			
		||||
            provider.ProviderIds[MetadataProvider.Imdb.ToString()] = ExampleImdbId;
 | 
			
		||||
 | 
			
		||||
            Assert.True(provider.HasProviderId(MetadataProvider.Imdb));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        [Fact]
 | 
			
		||||
        public void GetProviderId_NullInstance_ThrowsArgumentNullException()
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user