Browse Source

revert removal of null check

cvium 4 years ago
parent
commit
a49f5d2a44

+ 6 - 0
MediaBrowser.Model/Entities/ProviderIdsExtensions.cs

@@ -50,6 +50,12 @@ namespace MediaBrowser.Model.Entities
                 throw new ArgumentNullException(nameof(instance));
                 throw new ArgumentNullException(nameof(instance));
             }
             }
 
 
+            if (instance.ProviderIds == null)
+            {
+                id = null;
+                return false;
+            }
+
             var foundProviderId = instance.ProviderIds.TryGetValue(name, out id);
             var foundProviderId = instance.ProviderIds.TryGetValue(name, out id);
             // This occurs when searching with Identify (and possibly in other places)
             // This occurs when searching with Identify (and possibly in other places)
             if (string.IsNullOrEmpty(id))
             if (string.IsNullOrEmpty(id))

+ 5 - 5
tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs

@@ -18,7 +18,7 @@ namespace Jellyfin.Model.Tests.Entities
         [Fact]
         [Fact]
         public void HasProviderId_NullProvider_False()
         public void HasProviderId_NullProvider_False()
         {
         {
-            var nullProvider = new ProviderIdsExtensionsTestsObject()
+            var nullProvider = new ProviderIdsExtensionsTestsObject
             {
             {
                 ProviderIds = null!
                 ProviderIds = null!
             };
             };
@@ -68,7 +68,7 @@ namespace Jellyfin.Model.Tests.Entities
         [Fact]
         [Fact]
         public void GetProviderId_NullProvider_Null()
         public void GetProviderId_NullProvider_Null()
         {
         {
-            var nullProvider = new ProviderIdsExtensionsTestsObject()
+            var nullProvider = new ProviderIdsExtensionsTestsObject
             {
             {
                 ProviderIds = null!
                 ProviderIds = null!
             };
             };
@@ -85,7 +85,7 @@ namespace Jellyfin.Model.Tests.Entities
         [Fact]
         [Fact]
         public void TryGetProviderId_NullProvider_False()
         public void TryGetProviderId_NullProvider_False()
         {
         {
-            var nullProvider = new ProviderIdsExtensionsTestsObject()
+            var nullProvider = new ProviderIdsExtensionsTestsObject
             {
             {
                 ProviderIds = null!
                 ProviderIds = null!
             };
             };
@@ -146,7 +146,7 @@ namespace Jellyfin.Model.Tests.Entities
         [Fact]
         [Fact]
         public void SetProviderId_NullProvider_Success()
         public void SetProviderId_NullProvider_Success()
         {
         {
-            var nullProvider = new ProviderIdsExtensionsTestsObject()
+            var nullProvider = new ProviderIdsExtensionsTestsObject
             {
             {
                 ProviderIds = null!
                 ProviderIds = null!
             };
             };
@@ -158,7 +158,7 @@ namespace Jellyfin.Model.Tests.Entities
         [Fact]
         [Fact]
         public void SetProviderId_NullProviderAndEmptyName_Success()
         public void SetProviderId_NullProviderAndEmptyName_Success()
         {
         {
-            var nullProvider = new ProviderIdsExtensionsTestsObject()
+            var nullProvider = new ProviderIdsExtensionsTestsObject
             {
             {
                 ProviderIds = null!
                 ProviderIds = null!
             };
             };