using System.Collections.Generic; using System.Text.Json; using Jellyfin.Plugin.Floatplane.Api.Models; using Jellyfin.Plugin.Floatplane.Channel; using Xunit; namespace Jellyfin.Plugin.Floatplane.Tests; public class AllVideosTests { [Theory] [InlineData("post:SSvhppI28t", "SSvhppI28t")] [InlineData("cpost:64135da7ce81077a8480c679:SSvhppI28t", "SSvhppI28t")] [InlineData("creator:59f94c0bdd241b70349eb72b", null)] [InlineData("all:59f94c0bdd241b70349eb72b", null)] [InlineData("channel:a:b", null)] [InlineData("cpost:nochannel", null)] [InlineData("", null)] [InlineData(null, null)] public void PostIdOf_ParsesBothItemIdForms(string? externalId, string? expected) { Assert.Equal(expected, FloatplaneChannel.PostIdOf(externalId)); } [Fact] public void ToItem_UsesCanonicalIdByDefault_AndChannelPrefixWhenAsked() { var posts = Fixture.Json>("content-creator.json"); var post = posts[0]; var canonical = FloatplaneChannel.ToItem(post, null); var inChannel = FloatplaneChannel.ToItem(post, null, true, "cpost:" + post.Channel!.Id + ":"); Assert.Equal("post:" + post.Id, canonical.Id); Assert.Equal("cpost:" + post.Channel.Id + ":" + post.Id, inChannel.Id); Assert.Equal(canonical.Name, inChannel.Name); Assert.Equal(post.Id, FloatplaneChannel.PostIdOf(canonical.Id)); Assert.Equal(post.Id, FloatplaneChannel.PostIdOf(inChannel.Id)); Assert.NotEqual(FloatplaneChannel.DeterministicGuid(canonical.Id), FloatplaneChannel.DeterministicGuid(inChannel.Id)); } } public class SortNameTests { [Fact] public void NewerReleaseSortsFirstUnderAscendingNameOrder() { var older = SortNameUpdater.SortNameFor(new System.DateTime(2026, 10, 1, 0, 0, 0, System.DateTimeKind.Utc)); var newer = SortNameUpdater.SortNameFor(new System.DateTime(2026, 10, 24, 18, 24, 0, System.DateTimeKind.Utc)); Assert.Equal(13, older.Length); Assert.Equal(13, newer.Length); Assert.True(string.CompareOrdinal(newer, older) < 0, "newer must sort before older"); Assert.Equal(13, SortNameUpdater.SortNameFor(null).Length); } }