fix HasProviderId and add tests

This commit is contained in:
cvium 2021-03-03 12:28:40 +01:00
parent a49f5d2a44
commit 8b72b902f5
2 changed files with 20 additions and 1 deletions

View File

@ -22,7 +22,7 @@ namespace MediaBrowser.Model.Entities
throw new ArgumentNullException(nameof(instance));
}
return instance.ProviderIds?.ContainsKey(name) ?? false;
return instance.TryGetProviderId(name, out _);
}
/// <summary>

View File

@ -47,6 +47,15 @@ namespace Jellyfin.Model.Tests.Entities
Assert.True(provider.HasProviderId(MetadataProvider.Imdb));
}
[Fact]
public void HasProviderId_FoundNameEmptyValue_False()
{
var provider = new ProviderIdsExtensionsTestsObject();
provider.ProviderIds[MetadataProvider.Imdb.ToString()] = string.Empty;
Assert.False(provider.HasProviderId(MetadataProvider.Imdb));
}
[Fact]
public void GetProviderId_NullInstance_ThrowsArgumentNullException()
{
@ -112,6 +121,16 @@ namespace Jellyfin.Model.Tests.Entities
Assert.Equal(ExampleImdbId, id);
}
[Fact]
public void TryGetProviderId_FoundNameEmptyValue_False()
{
var provider = new ProviderIdsExtensionsTestsObject();
provider.ProviderIds[MetadataProvider.Imdb.ToString()] = string.Empty;
Assert.False(provider.TryGetProviderId(MetadataProvider.Imdb, out var id));
Assert.Null(id);
}
[Fact]
public void SetProviderId_NullInstance_ThrowsArgumentNullException()
{