diff options
| author | cvium <clausvium@gmail.com> | 2021-03-03 09:37:21 +0100 |
|---|---|---|
| committer | cvium <clausvium@gmail.com> | 2021-03-03 09:37:21 +0100 |
| commit | a49f5d2a441d53076c0eae27fc115a97691f4856 (patch) | |
| tree | 8d5222f8f0affed11f258e7591087a5564bd8f4d | |
| parent | 664c5da31728e65d0e53ada7c06c918059f73615 (diff) | |
revert removal of null check
| -rw-r--r-- | MediaBrowser.Model/Entities/ProviderIdsExtensions.cs | 6 | ||||
| -rw-r--r-- | tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs | 10 |
2 files changed, 11 insertions, 5 deletions
diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index 571bc7006..3086fcefd 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -50,6 +50,12 @@ namespace MediaBrowser.Model.Entities throw new ArgumentNullException(nameof(instance)); } + if (instance.ProviderIds == null) + { + id = null; + return false; + } + var foundProviderId = instance.ProviderIds.TryGetValue(name, out id); // This occurs when searching with Identify (and possibly in other places) if (string.IsNullOrEmpty(id)) diff --git a/tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs b/tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs index 2b2414ef1..cf9fb15d7 100644 --- a/tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs +++ b/tests/Jellyfin.Model.Tests/Entities/ProviderIdsExtensionsTests.cs @@ -18,7 +18,7 @@ namespace Jellyfin.Model.Tests.Entities [Fact] public void HasProviderId_NullProvider_False() { - var nullProvider = new ProviderIdsExtensionsTestsObject() + var nullProvider = new ProviderIdsExtensionsTestsObject { ProviderIds = null! }; @@ -68,7 +68,7 @@ namespace Jellyfin.Model.Tests.Entities [Fact] public void GetProviderId_NullProvider_Null() { - var nullProvider = new ProviderIdsExtensionsTestsObject() + var nullProvider = new ProviderIdsExtensionsTestsObject { ProviderIds = null! }; @@ -85,7 +85,7 @@ namespace Jellyfin.Model.Tests.Entities [Fact] public void TryGetProviderId_NullProvider_False() { - var nullProvider = new ProviderIdsExtensionsTestsObject() + var nullProvider = new ProviderIdsExtensionsTestsObject { ProviderIds = null! }; @@ -146,7 +146,7 @@ namespace Jellyfin.Model.Tests.Entities [Fact] public void SetProviderId_NullProvider_Success() { - var nullProvider = new ProviderIdsExtensionsTestsObject() + var nullProvider = new ProviderIdsExtensionsTestsObject { ProviderIds = null! }; @@ -158,7 +158,7 @@ namespace Jellyfin.Model.Tests.Entities [Fact] public void SetProviderId_NullProviderAndEmptyName_Success() { - var nullProvider = new ProviderIdsExtensionsTestsObject() + var nullProvider = new ProviderIdsExtensionsTestsObject { ProviderIds = null! }; |
