aboutsummaryrefslogtreecommitdiff
path: root/tests/Jellyfin.Server.Implementations.Tests/Data/ItemTypeLookupTests.cs
blob: a60622902bcd5266208f6137268e9271c8035f09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Linq;
using Emby.Server.Implementations.Data;
using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities;
using Xunit;

namespace Jellyfin.Server.Implementations.Tests.Data;

public class ItemTypeLookupTests
{
    public static TheoryData<BaseItemKind> MappedKinds()
        => new(new ItemTypeLookup().BaseItemKindNames.Keys);

    [Theory]
    [MemberData(nameof(MappedKinds))]
    public void BaseItemKindNames_Kind_NamesAnItemType(BaseItemKind kind)
    {
        var name = new ItemTypeLookup().BaseItemKindNames[kind];

        var type = AppDomain.CurrentDomain.GetAssemblies().Select(a => a.GetType(name)).FirstOrDefault(t => t is not null);

        Assert.NotNull(type);
        Assert.True(typeof(BaseItem).IsAssignableFrom(type), $"{name} is not an item type.");
    }
}