Add tests for ProviderIdsExtensions

This commit is contained in:
Bond_009
2021-02-19 17:01:52 +01:00
parent b2700ecf44
commit 941d3f6217
2 changed files with 140 additions and 30 deletions

View File

@@ -9,28 +9,6 @@ namespace MediaBrowser.Model.Entities
/// </summary>
public static class ProviderIdsExtensions
{
/// <summary>
/// Determines whether [has provider identifier] [the specified instance].
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="provider">The provider.</param>
/// <returns><c>true</c> if [has provider identifier] [the specified instance]; otherwise, <c>false</c>.</returns>
public static bool HasProviderId(this IHasProviderIds instance, MetadataProvider provider)
{
return !string.IsNullOrEmpty(instance.GetProviderId(provider.ToString()));
}
/// <summary>
/// Gets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="provider">The provider.</param>
/// <returns>System.String.</returns>
public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider)
{
return instance.GetProviderId(provider.ToString());
}
/// <summary>
/// Gets a provider id.
/// </summary>
@@ -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;
}
/// <summary>
/// Gets a provider id.
/// </summary>
/// <param name="instance">The instance.</param>
/// <param name="provider">The provider.</param>
/// <returns>System.String.</returns>
public static string? GetProviderId(this IHasProviderIds instance, MetadataProvider provider)
{
return instance.GetProviderId(provider.ToString());
}
/// <summary>
/// Sets a provider id.
/// </summary>
@@ -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
{