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) - [Tim Hobbs](https://github.com/timhobbs)
- [SvenVandenbrande](https://github.com/SvenVandenbrande) - [SvenVandenbrande](https://github.com/SvenVandenbrande)
- [olsh](https://github.com/olsh) - [olsh](https://github.com/olsh)
- [lbenini](https://github.com/lbenini)
- [gnuyent](https://github.com/gnuyent) - [gnuyent](https://github.com/gnuyent)

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

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