//
// Copyright (c) PlaceholderCompany. All rights reserved.
//
namespace Jellyfin.Controller.Tests.Entities
{
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.MediaInfo;
using Moq;
using Xunit;
///
/// Tests for .
///
public class BaseItemTests
{
///
/// Tests that ModifySortChunks correctly modifies sort chunks.
///
/// The input string.
/// The expected output string.
[Theory]
[InlineData("", "")]
[InlineData("1", "0000000001")]
[InlineData("t", "t")]
[InlineData("test", "test")]
[InlineData("test1", "test0000000001")]
[InlineData("1test 2", "0000000001test 0000000002")]
public void BaseItem_ModifySortChunks_Valid(string input, string expected)
{
Assert.Equal(expected, BaseItem.ModifySortChunks(input));
}
///
/// Tests that GetMediaSourceName returns the correct name for media sources.
///
/// The primary path.
/// The alternate path.
/// The expected name for the primary path.
/// The expected name for the alternate path.
[Theory]
[InlineData("/Movies/Ted/Ted.mp4", "/Movies/Ted/Ted - Unrated Edition.mp4", "Ted", "Unrated Edition")]
[InlineData("/Movies/Deadpool 2 (2018)/Deadpool 2 (2018).mkv", "/Movies/Deadpool 2 (2018)/Deadpool 2 (2018) - Super Duper Cut.mkv", "Deadpool 2 (2018)", "Super Duper Cut")]
public void GetMediaSourceName_Valid(string primaryPath, string altPath, string name, string altName)
{
Mock mediaSourceManager = new();
_ = mediaSourceManager.Setup(x => x.GetPathProtocol(It.IsAny()))
.Returns((string x) => MediaProtocol.File);
BaseItem.MediaSourceManager = mediaSourceManager.Object;
Video video = new()
{
Path = primaryPath,
};
Video videoAlt = new()
{
Path = altPath,
};
video.LocalAlternateVersions = [videoAlt.Path];
Assert.Equal(name, video.GetMediaSourceName(video));
Assert.Equal(altName, video.GetMediaSourceName(videoAlt));
}
}
}