Merge pull request #5228 from lbenini/baseitemkind-fixes

pull/5853/head^2
Claus Vium 3 years ago committed by GitHub
commit e15fea5dad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -212,4 +212,5 @@
- [Tim Hobbs](https://github.com/timhobbs)
- [SvenVandenbrande](https://github.com/SvenVandenbrande)
- [olsh](https://github.com/olsh)
- [lbenini](https://github.com/lbenini)
- [gnuyent](https://github.com/gnuyent)

@ -49,5 +49,10 @@ namespace Emby.Server.Implementations.Playlists
query.Parent = null;
return LibraryManager.GetItemsResult(query);
}
public override string GetClientTypeName()
{
return "ManualPlaylistsFolder";
}
}
}

@ -78,6 +78,16 @@
/// </summary>
Movie,
/// <summary>
/// Item is a live tv channel.
/// </summary>
LiveTvChannel,
/// <summary>
/// Item is a live tv program.
/// </summary>
LiveTvProgram,
/// <summary>
/// Item is music album.
/// </summary>
@ -118,6 +128,11 @@
/// </summary>
Playlist,
/// <summary>
/// Item is playlist folder.
/// </summary>
PlaylistsFolder,
/// <summary>
/// Item is program
/// </summary>

@ -0,0 +1,63 @@
using System;
using System.Linq;
using Jellyfin.Data.Enums;
using Xunit;
namespace Jellyfin.Server.Implementations.Tests.TypedBaseItem
{
public class BaseItemKindTests
{
public static TheoryData<Type> BaseItemKind_TestData()
{
var data = new TheoryData<Type>();
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (var assembly in loadedAssemblies)
{
if (IsProjectAssemblyName(assembly.FullName))
{
var baseItemTypes = assembly.GetTypes()
.Where(targetType => targetType.IsClass
&& !targetType.IsAbstract
&& targetType.IsSubclassOf(typeof(MediaBrowser.Controller.Entities.BaseItem)));
foreach (var baseItemType in baseItemTypes)
{
data.Add(baseItemType);
}
}
}
return data;
}
[Theory]
[MemberData(nameof(BaseItemKind_TestData))]
public void EnumParse_GivenValidBaseItemType_ReturnsEnumValue(Type baseItemDescendantType)
{
var enumValue = Enum.Parse<BaseItemKind>(baseItemDescendantType.Name);
Assert.True(Enum.IsDefined(typeof(BaseItemKind), enumValue));
}
[Theory]
[MemberData(nameof(BaseItemKind_TestData))]
public void GetBaseItemKind_WhenCalledAfterDefaultCtor_DoesNotThrow(Type baseItemDescendantType)
{
var defaultConstructor = baseItemDescendantType.GetConstructor(Type.EmptyTypes);
var instance = (MediaBrowser.Controller.Entities.BaseItem)defaultConstructor!.Invoke(null);
var exception = Record.Exception(() => instance.GetBaseItemKind());
Assert.Null(exception);
}
private static bool IsProjectAssemblyName(string? name)
{
if (name == null)
{
return false;
}
return name.StartsWith("Jellyfin", StringComparison.OrdinalIgnoreCase)
|| name.StartsWith("Emby", StringComparison.OrdinalIgnoreCase)
|| name.StartsWith("MediaBrowser", StringComparison.OrdinalIgnoreCase);
}
}
}
Loading…
Cancel
Save