From 941d3f621708089f8ca2feb89bb7e8de1bbf7d6d Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Fri, 19 Feb 2021 17:01:52 +0100 Subject: Add tests for ProviderIdsExtensions --- .../Entities/ProviderIdsExtensions.cs | 43 +++++++--------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'MediaBrowser.Model') diff --git a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs index c643f1ecd..4aff6e3a4 100644 --- a/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs +++ b/MediaBrowser.Model/Entities/ProviderIdsExtensions.cs @@ -9,28 +9,6 @@ namespace MediaBrowser.Model.Entities /// public static class ProviderIdsExtensions { - /// - /// Determines whether [has provider identifier] [the specified instance]. - /// - /// The instance. - /// The provider. - /// true if [has provider identifier] [the specified instance]; otherwise, false. - public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider) - { - return !string.IsNullOrEmpty(instance.GetProviderId(provider.ToString())); - } - - /// - /// Gets a provider id. - /// - /// The instance. - /// The provider. - /// System.String. - public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider) - { - return instance.GetProviderId(provider.ToString()); - } - /// /// Gets a provider id. /// @@ -47,7 +25,7 @@ namespace MediaBrowser.Model.Entities if (instance.ProviderIds == null) { - id = string.Empty; + id = null; return false; } @@ -78,6 +56,17 @@ namespace MediaBrowser.Model.Entities return id; } + /// + /// Gets a provider id. + /// + /// The instance. + /// The provider. + /// System.String. + public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider) + { + return instance.GetProviderId(provider.ToString()); + } + /// /// Sets a provider id. /// @@ -94,13 +83,7 @@ namespace MediaBrowser.Model.Entities // If it's null remove the key from the dictionary if (string.IsNullOrEmpty(value)) { - if (instance.ProviderIds != null) - { - if (instance.ProviderIds.ContainsKey(name)) - { - instance.ProviderIds.Remove(name); - } - } + instance.ProviderIds?.Remove(name); } else { -- cgit v1.2.3