aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Directory.Build.props2
-rw-r--r--tests/Jellyfin.Api.Tests/Controllers/UserControllerTests.cs120
-rw-r--r--tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs36
-rw-r--r--tests/Jellyfin.Api.Tests/Middleware/UrlDecodeQueryFeatureTests.cs (renamed from tests/Jellyfin.Server.Tests/UrlDecodeQueryFeatureTests.cs)3
-rw-r--r--tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs131
-rw-r--r--tests/Jellyfin.Dlna.Tests/GetUuidTests.cs17
-rw-r--r--tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj18
-rw-r--r--tests/Jellyfin.Dlna.Tests/Server/DescriptionXmlBuilderTests.cs47
-rw-r--r--tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedArrayTests.cs65
-rw-r--r--tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedIReadOnlyListTests.cs43
-rw-r--r--tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeExternalSourcesTests.cs50
-rw-r--r--tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs8
-rw-r--r--tests/Jellyfin.Naming.Tests/ExternalFiles/ExternalPathParserTests.cs6
-rw-r--r--tests/Jellyfin.Naming.Tests/Music/MultiDiscAlbumTests.cs56
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/DailyEpisodeTests.cs10
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/EpisodeNumberWithoutSeasonTests.cs20
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/EpisodePathParserTest.cs8
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs114
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs34
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/SeasonNumberTests.cs4
-rw-r--r--tests/Jellyfin.Naming.Tests/TV/SimpleEpisodeTests.cs4
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs60
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs2
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs172
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/StackTests.cs4
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/StubTests.cs2
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs56
-rw-r--r--tests/Jellyfin.Naming.Tests/Video/VideoResolverTests.cs36
-rw-r--r--tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs2
-rw-r--r--tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj2
-rw-r--r--tests/Jellyfin.Networking.Tests/NetworkExtensionsTests.cs10
-rw-r--r--tests/Jellyfin.Networking.Tests/NetworkManagerTests.cs2
-rw-r--r--tests/Jellyfin.Networking.Tests/NetworkParseTests.cs23
-rw-r--r--tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs18
-rw-r--r--tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs8
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Library/AudioResolverTests.cs3
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Library/EpisodeResolverTest.cs5
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs24
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Plugins/PluginManagerTests.cs18
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/SessionManager/SessionManagerTests.cs111
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Sorting/AiredEpisodeOrderComparerTests.cs11
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Sorting/IndexNumberComparerTests.cs2
-rw-r--r--tests/Jellyfin.Server.Implementations.Tests/Sorting/ParentIndexNumberComparerTests.cs2
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs154
-rw-r--r--tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs21
-rw-r--r--tests/Jellyfin.Server.Tests/ParseNetworkTests.cs5
-rw-r--r--tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs2
47 files changed, 726 insertions, 825 deletions
diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props
index de8fc1bb8..bec3481cb 100644
--- a/tests/Directory.Build.props
+++ b/tests/Directory.Build.props
@@ -4,7 +4,7 @@
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
<PropertyGroup>
- <TargetFramework>net7.0</TargetFramework>
+ <TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)/jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
diff --git a/tests/Jellyfin.Api.Tests/Controllers/UserControllerTests.cs b/tests/Jellyfin.Api.Tests/Controllers/UserControllerTests.cs
new file mode 100644
index 000000000..c7331c718
--- /dev/null
+++ b/tests/Jellyfin.Api.Tests/Controllers/UserControllerTests.cs
@@ -0,0 +1,120 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Threading.Tasks;
+using AutoFixture.Xunit2;
+using Jellyfin.Api.Controllers;
+using Jellyfin.Data.Entities;
+using MediaBrowser.Common.Net;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Devices;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Net;
+using MediaBrowser.Controller.Playlists;
+using MediaBrowser.Controller.QuickConnect;
+using MediaBrowser.Controller.Session;
+using MediaBrowser.Model.Users;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+using Moq;
+using Nikse.SubtitleEdit.Core.Common;
+using Xunit;
+
+namespace Jellyfin.Api.Tests.Controllers;
+
+public class UserControllerTests
+{
+ private readonly UserController _subject;
+ private readonly Mock<IUserManager> _mockUserManager;
+ private readonly Mock<ISessionManager> _mockSessionManager;
+ private readonly Mock<INetworkManager> _mockNetworkManager;
+ private readonly Mock<IDeviceManager> _mockDeviceManager;
+ private readonly Mock<IAuthorizationContext> _mockAuthorizationContext;
+ private readonly Mock<IServerConfigurationManager> _mockServerConfigurationManager;
+ private readonly Mock<ILogger<UserController>> _mockLogger;
+ private readonly Mock<IQuickConnect> _mockQuickConnect;
+ private readonly Mock<IPlaylistManager> _mockPlaylistManager;
+
+ public UserControllerTests()
+ {
+ _mockUserManager = new Mock<IUserManager>();
+ _mockSessionManager = new Mock<ISessionManager>();
+ _mockNetworkManager = new Mock<INetworkManager>();
+ _mockDeviceManager = new Mock<IDeviceManager>();
+ _mockAuthorizationContext = new Mock<IAuthorizationContext>();
+ _mockServerConfigurationManager = new Mock<IServerConfigurationManager>();
+ _mockLogger = new Mock<ILogger<UserController>>();
+ _mockQuickConnect = new Mock<IQuickConnect>();
+ _mockPlaylistManager = new Mock<IPlaylistManager>();
+
+ _subject = new UserController(
+ _mockUserManager.Object,
+ _mockSessionManager.Object,
+ _mockNetworkManager.Object,
+ _mockDeviceManager.Object,
+ _mockAuthorizationContext.Object,
+ _mockServerConfigurationManager.Object,
+ _mockLogger.Object,
+ _mockQuickConnect.Object,
+ _mockPlaylistManager.Object);
+ }
+
+ [Theory]
+ [AutoData]
+ public async Task UpdateUserPolicy_WhenUserNotFound_ReturnsNotFound(Guid userId, UserPolicy userPolicy)
+ {
+ User? nullUser = null;
+ _mockUserManager.
+ Setup(m => m.GetUserById(userId))
+ .Returns(nullUser);
+
+ Assert.IsType<NotFoundResult>(await _subject.UpdateUserPolicy(userId, userPolicy));
+ }
+
+ [Theory]
+ [InlineAutoData(null)]
+ [InlineAutoData("")]
+ [InlineAutoData(" ")]
+ public void UpdateUserPolicy_WhenPasswordResetProviderIdNotSupplied_ReturnsBadRequest(string? passwordResetProviderId)
+ {
+ var userPolicy = new UserPolicy
+ {
+ PasswordResetProviderId = passwordResetProviderId,
+ AuthenticationProviderId = "AuthenticationProviderId"
+ };
+
+ Assert.Contains(
+ Validate(userPolicy), v =>
+ v.MemberNames.Contains("PasswordResetProviderId") &&
+ v.ErrorMessage != null &&
+ v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ [Theory]
+ [InlineAutoData(null)]
+ [InlineAutoData("")]
+ [InlineAutoData(" ")]
+ public void UpdateUserPolicy_WhenAuthenticationProviderIdNotSupplied_ReturnsBadRequest(string? authenticationProviderId)
+ {
+ var userPolicy = new UserPolicy
+ {
+ AuthenticationProviderId = authenticationProviderId,
+ PasswordResetProviderId = "PasswordResetProviderId"
+ };
+
+ Assert.Contains(Validate(userPolicy), v =>
+ v.MemberNames.Contains("AuthenticationProviderId") &&
+ v.ErrorMessage != null &&
+ v.ErrorMessage.Contains("required", StringComparison.CurrentCultureIgnoreCase));
+ }
+
+ private List<ValidationResult> Validate(object model)
+ {
+ var result = new List<ValidationResult>();
+ var context = new ValidationContext(model, null, null);
+ Validator.TryValidateObject(model, context, result, true);
+
+ return result;
+ }
+}
diff --git a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
index 2d7741d81..a2d1b3607 100644
--- a/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
+++ b/tests/Jellyfin.Api.Tests/Helpers/RequestHelpersTests.cs
@@ -14,7 +14,7 @@ namespace Jellyfin.Api.Tests.Helpers
{
[Theory]
[MemberData(nameof(GetOrderBy_Success_TestData))]
- public static void GetOrderBy_Success(IReadOnlyList<string> sortBy, IReadOnlyList<SortOrder> requestedSortOrder, (string, SortOrder)[] expected)
+ public static void GetOrderBy_Success(IReadOnlyList<ItemSortBy> sortBy, IReadOnlyList<SortOrder> requestedSortOrder, (ItemSortBy, SortOrder)[] expected)
{
Assert.Equal(expected, RequestHelpers.GetOrderBy(sortBy, requestedSortOrder));
}
@@ -95,42 +95,42 @@ namespace Jellyfin.Api.Tests.Helpers
Assert.Throws<SecurityException>(() => RequestHelpers.GetUserId(principal, requestUserId));
}
- public static TheoryData<IReadOnlyList<string>, IReadOnlyList<SortOrder>, (string, SortOrder)[]> GetOrderBy_Success_TestData()
+ public static TheoryData<IReadOnlyList<ItemSortBy>, IReadOnlyList<SortOrder>, (ItemSortBy, SortOrder)[]> GetOrderBy_Success_TestData()
{
- var data = new TheoryData<IReadOnlyList<string>, IReadOnlyList<SortOrder>, (string, SortOrder)[]>();
+ var data = new TheoryData<IReadOnlyList<ItemSortBy>, IReadOnlyList<SortOrder>, (ItemSortBy, SortOrder)[]>();
data.Add(
- Array.Empty<string>(),
+ Array.Empty<ItemSortBy>(),
Array.Empty<SortOrder>(),
- Array.Empty<(string, SortOrder)>());
+ Array.Empty<(ItemSortBy, SortOrder)>());
data.Add(
- new string[]
+ new[]
{
- "IsFavoriteOrLiked",
- "Random"
+ ItemSortBy.IsFavoriteOrLiked,
+ ItemSortBy.Random
},
Array.Empty<SortOrder>(),
- new (string, SortOrder)[]
+ new (ItemSortBy, SortOrder)[]
{
- ("IsFavoriteOrLiked", SortOrder.Ascending),
- ("Random", SortOrder.Ascending),
+ (ItemSortBy.IsFavoriteOrLiked, SortOrder.Ascending),
+ (ItemSortBy.Random, SortOrder.Ascending),
});
data.Add(
- new string[]
+ new[]
{
- "SortName",
- "ProductionYear"
+ ItemSortBy.SortName,
+ ItemSortBy.ProductionYear
},
- new SortOrder[]
+ new[]
{
SortOrder.Descending
},
- new (string, SortOrder)[]
+ new (ItemSortBy, SortOrder)[]
{
- ("SortName", SortOrder.Descending),
- ("ProductionYear", SortOrder.Descending),
+ (ItemSortBy.SortName, SortOrder.Descending),
+ (ItemSortBy.ProductionYear, SortOrder.Descending),
});
return data;
diff --git a/tests/Jellyfin.Server.Tests/UrlDecodeQueryFeatureTests.cs b/tests/Jellyfin.Api.Tests/Middleware/UrlDecodeQueryFeatureTests.cs
index 93e065685..1ff7e7b7a 100644
--- a/tests/Jellyfin.Server.Tests/UrlDecodeQueryFeatureTests.cs
+++ b/tests/Jellyfin.Api.Tests/Middleware/UrlDecodeQueryFeatureTests.cs
@@ -1,12 +1,11 @@
using System.Collections.Generic;
using System.Linq;
-using Jellyfin.Api.Middleware;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Primitives;
using Xunit;
-namespace Jellyfin.Server.Tests
+namespace Jellyfin.Api.Middleware.Tests
{
public static class UrlDecodeQueryFeatureTests
{
diff --git a/tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs b/tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs
deleted file mode 100644
index 78a956f5f..000000000
--- a/tests/Jellyfin.Dlna.Tests/DlnaManagerTests.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using Emby.Dlna;
-using Emby.Dlna.PlayTo;
-using MediaBrowser.Common.Configuration;
-using MediaBrowser.Controller;
-using MediaBrowser.Model.Dlna;
-using MediaBrowser.Model.IO;
-using MediaBrowser.Model.Serialization;
-using Microsoft.Extensions.Logging;
-using Moq;
-using Xunit;
-
-namespace Jellyfin.Dlna.Tests
-{
- public class DlnaManagerTests
- {
- private DlnaManager GetManager()
- {
- var xmlSerializer = new Mock<IXmlSerializer>();
- var fileSystem = new Mock<IFileSystem>();
- var appPaths = new Mock<IApplicationPaths>();
- var loggerFactory = new Mock<ILoggerFactory>();
- var appHost = new Mock<IServerApplicationHost>();
-
- return new DlnaManager(xmlSerializer.Object, fileSystem.Object, appPaths.Object, loggerFactory.Object, appHost.Object);
- }
-
- [Fact]
- public void IsMatch_GivenMatchingName_ReturnsTrue()
- {
- var device = new DeviceInfo()
- {
- Name = "My Device",
- Manufacturer = "LG Electronics",
- ManufacturerUrl = "http://www.lge.com",
- ModelDescription = "LG WebOSTV DMRplus",
- ModelName = "LG TV",
- ModelNumber = "1.0",
- };
-
- var profile = new DeviceProfile()
- {
- Name = "Test Profile",
- FriendlyName = "My Device",
- Manufacturer = "LG Electronics",
- ManufacturerUrl = "http://www.lge.com",
- ModelDescription = "LG WebOSTV DMRplus",
- ModelName = "LG TV",
- ModelNumber = "1.0",
- Identification = new()
- {
- FriendlyName = "My Device",
- Manufacturer = "LG Electronics",
- ManufacturerUrl = "http://www.lge.com",
- ModelDescription = "LG WebOSTV DMRplus",
- ModelName = "LG TV",
- ModelNumber = "1.0",
- }
- };
-
- var profile2 = new DeviceProfile()
- {
- Name = "Test Profile",
- FriendlyName = "My Device",
- Identification = new DeviceIdentification()
- {
- FriendlyName = "My Device",
- }
- };
-
- var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile2.Identification);
- var deviceMatch2 = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
-
- Assert.True(deviceMatch);
- Assert.True(deviceMatch2);
- }
-
- [Fact]
- public void IsMatch_GivenNamesAndManufacturersDoNotMatch_ReturnsFalse()
- {
- var device = new DeviceInfo()
- {
- Name = "My Device",
- Manufacturer = "JVC"
- };
-
- var profile = new DeviceProfile()
- {
- Name = "Test Profile",
- FriendlyName = "My Device",
- Manufacturer = "LG Electronics",
- ManufacturerUrl = "http://www.lge.com",
- ModelDescription = "LG WebOSTV DMRplus",
- ModelName = "LG TV",
- ModelNumber = "1.0",
- Identification = new()
- {
- FriendlyName = "My Device",
- Manufacturer = "LG Electronics",
- ManufacturerUrl = "http://www.lge.com",
- ModelDescription = "LG WebOSTV DMRplus",
- ModelName = "LG TV",
- ModelNumber = "1.0",
- }
- };
-
- var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
-
- Assert.False(deviceMatch);
- }
-
- [Fact]
- public void IsMatch_GivenNamesAndRegExMatch_ReturnsTrue()
- {
- var device = new DeviceInfo()
- {
- Name = "My Device"
- };
-
- var profile = new DeviceProfile()
- {
- Name = "Test Profile",
- FriendlyName = "My .*",
- Identification = new()
- };
-
- var deviceMatch = GetManager().IsMatch(device.ToDeviceIdentification(), profile.Identification);
-
- Assert.True(deviceMatch);
- }
- }
-}
diff --git a/tests/Jellyfin.Dlna.Tests/GetUuidTests.cs b/tests/Jellyfin.Dlna.Tests/GetUuidTests.cs
deleted file mode 100644
index 7655e3f7c..000000000
--- a/tests/Jellyfin.Dlna.Tests/GetUuidTests.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Emby.Dlna.PlayTo;
-using Xunit;
-
-namespace Jellyfin.Dlna.Tests
-{
- public static class GetUuidTests
- {
- [Theory]
- [InlineData("uuid:fc4ec57e-b051-11db-88f8-0060085db3f6::urn:schemas-upnp-org:device:WANDevice:1", "fc4ec57e-b051-11db-88f8-0060085db3f6")]
- [InlineData("uuid:IGD{8c80f73f-4ba0-45fa-835d-042505d052be}000000000000", "8c80f73f-4ba0-45fa-835d-042505d052be")]
- [InlineData("uuid:IGD{8c80f73f-4ba0-45fa-835d-042505d052be}000000000000::urn:schemas-upnp-org:device:InternetGatewayDevice:1", "8c80f73f-4ba0-45fa-835d-042505d052be")]
- [InlineData("uuid:00000000-0000-0000-0000-000000000000::upnp:rootdevice", "00000000-0000-0000-0000-000000000000")]
- [InlineData("uuid:fc4ec57e-b051-11db-88f8-0060085db3f6", "fc4ec57e-b051-11db-88f8-0060085db3f6")]
- public static void GetUuid_Valid_Success(string usn, string uuid)
- => Assert.Equal(uuid, PlayToManager.GetUuid(usn));
- }
-}
diff --git a/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj b/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj
deleted file mode 100644
index 69677ce42..000000000
--- a/tests/Jellyfin.Dlna.Tests/Jellyfin.Dlna.Tests.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-
- <ItemGroup>
- <PackageReference Include="Microsoft.NET.Test.Sdk" />
- <PackageReference Include="Moq" />
- <PackageReference Include="xunit" />
- <PackageReference Include="xunit.runner.visualstudio">
- <PrivateAssets>all</PrivateAssets>
- <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
- </PackageReference>
- <PackageReference Include="coverlet.collector" />
- </ItemGroup>
-
- <ItemGroup>
- <ProjectReference Include="../../Emby.Dlna/Emby.Dlna.csproj" />
- </ItemGroup>
-
-</Project>
diff --git a/tests/Jellyfin.Dlna.Tests/Server/DescriptionXmlBuilderTests.cs b/tests/Jellyfin.Dlna.Tests/Server/DescriptionXmlBuilderTests.cs
deleted file mode 100644
index c9018fe2f..000000000
--- a/tests/Jellyfin.Dlna.Tests/Server/DescriptionXmlBuilderTests.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using Emby.Dlna.Server;
-using MediaBrowser.Model.Dlna;
-using Xunit;
-
-namespace Jellyfin.Dlna.Server.Tests;
-
-public class DescriptionXmlBuilderTests
-{
- [Fact]
- public void GetFriendlyName_EmptyProfile_ReturnsServerName()
- {
- const string ServerName = "Test Server Name";
- var builder = new DescriptionXmlBuilder(new DeviceProfile(), "serverUdn", "localhost", ServerName, string.Empty);
- Assert.Equal(ServerName, builder.GetFriendlyName());
- }
-
- [Fact]
- public void GetFriendlyName_FriendlyName_ReturnsFriendlyName()
- {
- const string FriendlyName = "Friendly Neighborhood Test Server";
- var builder = new DescriptionXmlBuilder(
- new DeviceProfile()
- {
- FriendlyName = FriendlyName
- },
- "serverUdn",
- "localhost",
- "Test Server Name",
- string.Empty);
- Assert.Equal(FriendlyName, builder.GetFriendlyName());
- }
-
- [Fact]
- public void GetFriendlyName_FriendlyNameInterpolation_ReturnsFriendlyName()
- {
- var builder = new DescriptionXmlBuilder(
- new DeviceProfile()
- {
- FriendlyName = "Friendly Neighborhood ${HostName}"
- },
- "serverUdn",
- "localhost",
- "Test Server Name",
- string.Empty);
- Assert.Equal("Friendly Neighborhood TestServerName", builder.GetFriendlyName());
- }
-}
diff --git a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedArrayTests.cs b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedArrayTests.cs
index f2ca2ff08..61105b42b 100644
--- a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedArrayTests.cs
+++ b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedArrayTests.cs
@@ -7,135 +7,128 @@ using Xunit;
namespace Jellyfin.Extensions.Tests.Json.Converters
{
- public static class JsonCommaDelimitedArrayTests
+ public class JsonCommaDelimitedArrayTests
{
+ private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
+ {
+ Converters =
+ {
+ new JsonStringEnumConverter()
+ }
+ };
+
[Fact]
- public static void Deserialize_String_Null_Success()
+ public void Deserialize_String_Null_Success()
{
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": null }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": null }", _jsonOptions);
Assert.Null(value?.Value);
}
[Fact]
- public static void Deserialize_Empty_Success()
+ public void Deserialize_Empty_Success()
{
var desiredValue = new GenericBodyArrayModel<string>
{
Value = Array.Empty<string>()
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": """" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": """" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_String_Valid_Success()
+ public void Deserialize_String_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a,b,c"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a,b,c"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_String_Space_Valid_Success()
+ public void Deserialize_String_Space_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a, b, c"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": ""a, b, c"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Valid_Success()
+ public void Deserialize_GenericCommandType_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_EmptyEntry_Success()
+ public void Deserialize_GenericCommandType_EmptyEntry_Success()
{
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,,MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,,MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Invalid_Success()
+ public void Deserialize_GenericCommandType_Invalid_Success()
{
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,TotallyNotAVallidCommand,MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,TotallyNotAVallidCommand,MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Space_Valid_Success()
+ public void Deserialize_GenericCommandType_Space_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_String_Array_Valid_Success()
+ public void Deserialize_String_Array_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Array_Valid_Success()
+ public void Deserialize_GenericCommandType_Array_Valid_Success()
{
var desiredValue = new GenericBodyArrayModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyArrayModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
}
diff --git a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedIReadOnlyListTests.cs b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedIReadOnlyListTests.cs
index 92886dcd2..9b977b9a5 100644
--- a/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedIReadOnlyListTests.cs
+++ b/tests/Jellyfin.Extensions.Tests/Json/Converters/JsonCommaDelimitedIReadOnlyListTests.cs
@@ -6,86 +6,85 @@ using Xunit;
namespace Jellyfin.Extensions.Tests.Json.Converters
{
- public static class JsonCommaDelimitedIReadOnlyListTests
+ public class JsonCommaDelimitedIReadOnlyListTests
{
+ private readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions()
+ {
+ Converters =
+ {
+ new JsonStringEnumConverter()
+ }
+ };
+
[Fact]
- public static void Deserialize_String_Valid_Success()
+ public void Deserialize_String_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a,b,c"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a,b,c"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_String_Space_Valid_Success()
+ public void Deserialize_String_Space_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a, b, c"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": ""a, b, c"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Valid_Success()
+ public void Deserialize_GenericCommandType_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp,MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Space_Valid_Success()
+ public void Deserialize_GenericCommandType_Space_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": ""MoveUp, MoveDown"" }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_String_Array_Valid_Success()
+ public void Deserialize_String_Array_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<string>
{
Value = new[] { "a", "b", "c" }
};
- var options = new JsonSerializerOptions();
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<string>>(@"{ ""Value"": [""a"",""b"",""c""] }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
[Fact]
- public static void Deserialize_GenericCommandType_Array_Valid_Success()
+ public void Deserialize_GenericCommandType_Array_Valid_Success()
{
var desiredValue = new GenericBodyIReadOnlyListModel<GeneralCommandType>
{
Value = new[] { GeneralCommandType.MoveUp, GeneralCommandType.MoveDown }
};
- var options = new JsonSerializerOptions();
- options.Converters.Add(new JsonStringEnumConverter());
- var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", options);
+ var value = JsonSerializer.Deserialize<GenericBodyIReadOnlyListModel<GeneralCommandType>>(@"{ ""Value"": [""MoveUp"", ""MoveDown""] }", _jsonOptions);
Assert.Equal(desiredValue.Value, value?.Value);
}
}
diff --git a/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeExternalSourcesTests.cs b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeExternalSourcesTests.cs
new file mode 100644
index 000000000..263f74c90
--- /dev/null
+++ b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeExternalSourcesTests.cs
@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.MediaEncoding.Encoder;
+using MediaBrowser.Model.Globalization;
+using MediaBrowser.Model.IO;
+using MediaBrowser.Model.MediaInfo;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.Logging;
+using Moq;
+using Xunit;
+
+namespace Jellyfin.MediaEncoding.Tests.Probing
+{
+ public class ProbeExternalSourcesTests
+ {
+ [Fact]
+ public void GetExtraArguments_Forwards_UserAgent()
+ {
+ var encoder = new MediaEncoder(
+ Mock.Of<ILogger<MediaEncoder>>(),
+ Mock.Of<IServerConfigurationManager>(),
+ Mock.Of<IFileSystem>(),
+ Mock.Of<IBlurayExaminer>(),
+ Mock.Of<ILocalizationManager>(),
+ new ConfigurationBuilder().Build(),
+ Mock.Of<IServerConfigurationManager>());
+
+ var userAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)";
+ var req = new MediaBrowser.Controller.MediaEncoding.MediaInfoRequest()
+ {
+ MediaSource = new MediaBrowser.Model.Dto.MediaSourceInfo
+ {
+ Path = "/path/to/stream",
+ Protocol = MediaProtocol.Http,
+ RequiredHttpHeaders = new Dictionary<string, string>()
+ {
+ { "user_agent", userAgent },
+ }
+ },
+ ExtractChapters = false,
+ MediaType = MediaBrowser.Model.Dlna.DlnaProfileType.Video,
+ };
+
+ var extraArg = encoder.GetExtraArguments(req);
+
+ Assert.Contains(userAgent, extraArg, StringComparison.InvariantCulture);
+ }
+ }
+}
diff --git a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
index c72a3315e..9b9c1ec34 100644
--- a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
@@ -14,18 +14,18 @@ namespace Jellyfin.Naming.Tests.AudioBook
data.Add(
new AudioBookFileInfo(
- @"/server/AudioBooks/Larry Potter/Larry Potter.mp3",
+ "/server/AudioBooks/Larry Potter/Larry Potter.mp3",
"mp3"));
data.Add(
new AudioBookFileInfo(
- @"/server/AudioBooks/Berry Potter/Chapter 1 .ogg",
+ "/server/AudioBooks/Berry Potter/Chapter 1 .ogg",
"ogg",
chapterNumber: 1));
data.Add(
new AudioBookFileInfo(
- @"/server/AudioBooks/Nerry Potter/Part 3 - Chapter 2.mp3",
+ "/server/AudioBooks/Nerry Potter/Part 3 - Chapter 2.mp3",
"mp3",
chapterNumber: 2,
partNumber: 3));
@@ -49,7 +49,7 @@ namespace Jellyfin.Naming.Tests.AudioBook
[Fact]
public void Resolve_InvalidExtension()
{
- var result = new AudioBookResolver(_namingOptions).Resolve(@"/server/AudioBooks/Larry Potter/Larry Potter.mp9");
+ var result = new AudioBookResolver(_namingOptions).Resolve("/server/AudioBooks/Larry Potter/Larry Potter.mp9");
Assert.Null(result);
}
diff --git a/tests/Jellyfin.Naming.Tests/ExternalFiles/ExternalPathParserTests.cs b/tests/Jellyfin.Naming.Tests/ExternalFiles/ExternalPathParserTests.cs
index 97949adff..ba602b5d2 100644
--- a/tests/Jellyfin.Naming.Tests/ExternalFiles/ExternalPathParserTests.cs
+++ b/tests/Jellyfin.Naming.Tests/ExternalFiles/ExternalPathParserTests.cs
@@ -20,11 +20,11 @@ public class ExternalPathParserTests
var hindiCultureDto = new CultureDto("Hindi", "Hindi", "hi", new[] { "hin" });
var localizationManager = new Mock<ILocalizationManager>(MockBehavior.Loose);
- localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"en.*", RegexOptions.IgnoreCase)))
+ localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex("en.*", RegexOptions.IgnoreCase)))
.Returns(englishCultureDto);
- localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"fr.*", RegexOptions.IgnoreCase)))
+ localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex("fr.*", RegexOptions.IgnoreCase)))
.Returns(frenchCultureDto);
- localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"hi.*", RegexOptions.IgnoreCase)))
+ localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex("hi.*", RegexOptions.IgnoreCase)))
.Returns(hindiCultureDto);
_audioPathParser = new ExternalPathParser(new NamingOptions(), localizationManager.Object, DlnaProfileType.Audio);
diff --git a/tests/Jellyfin.Naming.Tests/Music/MultiDiscAlbumTests.cs b/tests/Jellyfin.Naming.Tests/Music/MultiDiscAlbumTests.cs
index c9a295a4c..471616797 100644
--- a/tests/Jellyfin.Naming.Tests/Music/MultiDiscAlbumTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Music/MultiDiscAlbumTests.cs
@@ -12,34 +12,34 @@ namespace Jellyfin.Naming.Tests.Music
[InlineData("", false)]
[InlineData("C:/", false)]
[InlineData("/home/", false)]
- [InlineData(@"blah blah", false)]
- [InlineData(@"D:/music/weezer/03 Pinkerton", false)]
- [InlineData(@"D:/music/michael jackson/Bad (2012 Remaster)", false)]
- [InlineData(@"cd1", true)]
- [InlineData(@"disc18", true)]
- [InlineData(@"disk10", true)]
- [InlineData(@"vol7", true)]
- [InlineData(@"volume1", true)]
- [InlineData(@"cd 1", true)]
- [InlineData(@"disc 1", true)]
- [InlineData(@"disk 1", true)]
- [InlineData(@"disk", false)]
- [InlineData(@"disk ·", false)]
- [InlineData(@"disk a", false)]
- [InlineData(@"disk volume", false)]
- [InlineData(@"disc disc", false)]
- [InlineData(@"disk disc 6", false)]
- [InlineData(@"cd - 1", true)]
- [InlineData(@"disc- 1", true)]
- [InlineData(@"disk - 1", true)]
- [InlineData(@"Disc 01 (Hugo Wolf · 24 Lieder)", true)]
- [InlineData(@"Disc 04 (Encores and Folk Songs)", true)]
- [InlineData(@"Disc04 (Encores and Folk Songs)", true)]
- [InlineData(@"Disc 04(Encores and Folk Songs)", true)]
- [InlineData(@"Disc04(Encores and Folk Songs)", true)]
- [InlineData(@"D:/Video/MBTestLibrary/VideoTest/music/.38 special/anth/Disc 2", true)]
- [InlineData(@"[1985] Opportunities (Let's make lots of money) (1985)", false)]
- [InlineData(@"Blah 04(Encores and Folk Songs)", false)]
+ [InlineData("blah blah", false)]
+ [InlineData("D:/music/weezer/03 Pinkerton", false)]
+ [InlineData("D:/music/michael jackson/Bad (2012 Remaster)", false)]
+ [InlineData("cd1", true)]
+ [InlineData("disc18", true)]
+ [InlineData("disk10", true)]
+ [InlineData("vol7", true)]
+ [InlineData("volume1", true)]
+ [InlineData("cd 1", true)]
+ [InlineData("disc 1", true)]
+ [InlineData("disk 1", true)]
+ [InlineData("disk", false)]
+ [InlineData("disk ·", false)]
+ [InlineData("disk a", false)]
+ [InlineData("disk volume", false)]
+ [InlineData("disc disc", false)]
+ [InlineData("disk disc 6", false)]
+ [InlineData("cd - 1", true)]
+ [InlineData("disc- 1", true)]
+ [InlineData("disk - 1", true)]
+ [InlineData("Disc 01 (Hugo Wolf · 24 Lieder)", true)]
+ [InlineData("Disc 04 (Encores and Folk Songs)", true)]
+ [InlineData("Disc04 (Encores and Folk Songs)", true)]
+ [InlineData("Disc 04(Encores and Folk Songs)", true)]
+ [InlineData("Disc04(Encores and Folk Songs)", true)]
+ [InlineData("D:/Video/MBTestLibrary/VideoTest/music/.38 special/anth/Disc 2", true)]
+ [InlineData("[1985] Opportunities (Let's make lots of money) (1985)", false)]
+ [InlineData("Blah 04(Encores and Folk Songs)", false)]
public void AlbumParser_MultidiscPath_Identifies(string path, bool result)
{
var parser = new AlbumParser(_namingOptions);
diff --git a/tests/Jellyfin.Naming.Tests/TV/DailyEpisodeTests.cs b/tests/Jellyfin.Naming.Tests/TV/DailyEpisodeTests.cs
index d0d3d8292..f2cd360e5 100644
--- a/tests/Jellyfin.Naming.Tests/TV/DailyEpisodeTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/DailyEpisodeTests.cs
@@ -9,11 +9,11 @@ namespace Jellyfin.Naming.Tests.TV
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
[Theory]
- [InlineData(@"/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)]
- [InlineData(@"/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)]
- [InlineData(@"/server/james.corden.2017.04.20.anne.hathaway.720p.hdtv.x264-crooks.mkv", "james.corden", 2017, 04, 20)]
- [InlineData(@"/server/ABC News 2018_03_24_19_00_00.mkv", "ABC News", 2018, 03, 24)]
- [InlineData(@"/server/Jeopardy 2023 07 14 HDTV x264 AC3.mkv", "Jeopardy", 2023, 07, 14)]
+ [InlineData("/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)]
+ [InlineData("/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)]
+ [InlineData("/server/james.corden.2017.04.20.anne.hathaway.720p.hdtv.x264-crooks.mkv", "james.corden", 2017, 04, 20)]
+ [InlineData("/server/ABC News 2018_03_24_19_00_00.mkv", "ABC News", 2018, 03, 24)]
+ [InlineData("/server/Jeopardy 2023 07 14 HDTV x264 AC3.mkv", "Jeopardy", 2023, 07, 14)]
// TODO: [InlineData(@"/server/anything_14.11.1996.mp4", "anything", 1996, 11, 14)]
// TODO: [InlineData(@"/server/A Daily Show - (2015-01-15) - Episode Name - [720p].mkv", "A Daily Show", 2015, 01, 15)]
// TODO: [InlineData(@"/server/Last Man Standing_KTLADT_2018_05_25_01_28_00.wtv", "Last Man Standing", 2018, 05, 25)]
diff --git a/tests/Jellyfin.Naming.Tests/TV/EpisodeNumberWithoutSeasonTests.cs b/tests/Jellyfin.Naming.Tests/TV/EpisodeNumberWithoutSeasonTests.cs
index 1da5a30a8..1727b2247 100644
--- a/tests/Jellyfin.Naming.Tests/TV/EpisodeNumberWithoutSeasonTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/EpisodeNumberWithoutSeasonTests.cs
@@ -9,16 +9,16 @@ namespace Jellyfin.Naming.Tests.TV
private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
[Theory]
- [InlineData(8, @"The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")]
- [InlineData(2, @"The Simpsons/The Simpsons - 02 - Ep Name.avi")]
- [InlineData(2, @"The Simpsons/02.avi")]
- [InlineData(2, @"The Simpsons/02 - Ep Name.avi")]
- [InlineData(2, @"The Simpsons/02-Ep Name.avi")]
- [InlineData(2, @"The Simpsons/02.EpName.avi")]
- [InlineData(2, @"The Simpsons/The Simpsons - 02.avi")]
- [InlineData(2, @"The Simpsons/The Simpsons - 02 Ep Name.avi")]
- [InlineData(7, @"GJ Club (2013)/GJ Club - 07.mkv")]
- [InlineData(17, @"Case Closed (1996-2007)/Case Closed - 317.mkv")]
+ [InlineData(8, "The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")]
+ [InlineData(2, "The Simpsons/The Simpsons - 02 - Ep Name.avi")]
+ [InlineData(2, "The Simpsons/02.avi")]
+ [InlineData(2, "The Simpsons/02 - Ep Name.avi")]
+ [InlineData(2, "The Simpsons/02-Ep Name.avi")]
+ [InlineData(2, "The Simpsons/02.EpName.avi")]
+ [InlineData(2, "The Simpsons/The Simpsons - 02.avi")]
+ [InlineData(2, "The Simpsons/The Simpsons - 02 Ep Name.avi")]
+ [InlineData(7, "GJ Club (2013)/GJ Club - 07.mkv")]
+ [InlineData(17, "Case Closed (1996-2007)/Case Closed - 317.mkv")]
// TODO: [InlineData(2, @"The Simpsons/The Simpsons 5 - 02 - Ep Name.avi")]
// TODO: [InlineData(2, @"The Simpsons/The Simpsons 5 - 02 Ep Name.avi")]
// TODO: [InlineData(7, @"Seinfeld/Seinfeld 0807 The Checks.avi")]
diff --git a/tests/Jellyfin.Naming.Tests/TV/EpisodePathParserTest.cs b/tests/Jellyfin.Naming.Tests/TV/EpisodePathParserTest.cs
index 7604ddc80..5397f1371 100644
--- a/tests/Jellyfin.Naming.Tests/TV/EpisodePathParserTest.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/EpisodePathParserTest.cs
@@ -13,10 +13,10 @@ namespace Jellyfin.Naming.Tests.TV
[InlineData("/media/Foo - S04E011", true, "Foo", 4, 11)]
[InlineData("/media/Foo/Foo s01x01", true, "Foo", 1, 1)]
[InlineData("/media/Foo (2019)/Season 4/Foo (2019).S04E03", true, "Foo (2019)", 4, 3)]
- [InlineData("D:\\media\\Foo\\Foo-S01E01", true, "Foo", 1, 1)]
- [InlineData("D:\\media\\Foo - S04E011", true, "Foo", 4, 11)]
- [InlineData("D:\\media\\Foo\\Foo s01x01", true, "Foo", 1, 1)]
- [InlineData("D:\\media\\Foo (2019)\\Season 4\\Foo (2019).S04E03", true, "Foo (2019)", 4, 3)]
+ [InlineData(@"D:\media\Foo\Foo-S01E01", true, "Foo", 1, 1)]
+ [InlineData(@"D:\media\Foo - S04E011", true, "Foo", 4, 11)]
+ [InlineData(@"D:\media\Foo\Foo s01x01", true, "Foo", 1, 1)]
+ [InlineData(@"D:\media\Foo (2019)\Season 4\Foo (2019).S04E03", true, "Foo (2019)", 4, 3)]
[InlineData("/Season 2/Elementary - 02x03-04-15 - Ep Name.mp4", false, "Elementary", 2, 3)]
[InlineData("/Season 1/seriesname S01E02 blah.avi", false, "seriesname", 1, 2)]
[InlineData("/Running Man/Running Man S2017E368.mkv", false, "Running Man", 2017, 368)]
diff --git a/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs b/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs
index ffaa64c3f..6d6591abf 100644
--- a/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/MultiEpisodeTests.cs
@@ -9,66 +9,66 @@ namespace Jellyfin.Naming.Tests.TV
private readonly EpisodePathParser _episodePathParser = new EpisodePathParser(new NamingOptions());
[Theory]
- [InlineData(@"Season 1/4x01 – 20 Hours in America (1).mkv", null)]
- [InlineData(@"Season 1/01x02 blah.avi", null)]
- [InlineData(@"Season 1/S01x02 blah.avi", null)]
- [InlineData(@"Season 1/S01E02 blah.avi", null)]
- [InlineData(@"Season 1/S01xE02 blah.avi", null)]
- [InlineData(@"Season 1/seriesname 01x02 blah.avi", null)]
- [InlineData(@"Season 1/seriesname S01x02 blah.avi", null)]
- [InlineData(@"Season 1/seriesname S01E02 blah.avi", null)]
- [InlineData(@"Season 1/seriesname S01xE02 blah.avi", null)]
- [InlineData(@"Season 2/02x03 - 04 Ep Name.mp4", null)]
- [InlineData(@"Season 2/My show name 02x03 - 04 Ep Name.mp4", null)]
- [InlineData(@"Season 2/Elementary - 02x03 - 02x04 - 02x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2/02x03 - 02x04 - 02x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2/02x03-04-15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2/Elementary - 02x03-04-15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/02x03-E15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/Elementary - 02x03-E15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/02x03 - x04 - x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/Elementary - 02x03 - x04 - x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/02x03x04x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 02/Elementary - 02x03x04x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 1/Elementary - S01E23-E24-E26 - The Woman.mp4", 26)]
- [InlineData(@"Season 1/S01E23-E24-E26 - The Woman.mp4", 26)]
+ [InlineData("Season 1/4x01 – 20 Hours in America (1).mkv", null)]
+ [InlineData("Season 1/01x02 blah.avi", null)]
+ [InlineData("Season 1/S01x02 blah.avi", null)]
+ [InlineData("Season 1/S01E02 blah.avi", null)]
+ [InlineData("Season 1/S01xE02 blah.avi", null)]
+ [InlineData("Season 1/seriesname 01x02 blah.avi", null)]
+ [InlineData("Season 1/seriesname S01x02 blah.avi", null)]
+ [InlineData("Season 1/seriesname S01E02 blah.avi", null)]
+ [InlineData("Season 1/seriesname S01xE02 blah.avi", null)]
+ [InlineData("Season 2/02x03 - 04 Ep Name.mp4", null)]
+ [InlineData("Season 2/My show name 02x03 - 04 Ep Name.mp4", null)]
+ [InlineData("Season 2/Elementary - 02x03 - 02x04 - 02x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2/02x03 - 02x04 - 02x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2/02x03-04-15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2/Elementary - 02x03-04-15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/02x03-E15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/Elementary - 02x03-E15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/02x03 - x04 - x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/Elementary - 02x03 - x04 - x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/02x03x04x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 02/Elementary - 02x03x04x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 1/Elementary - S01E23-E24-E26 - The Woman.mp4", 26)]
+ [InlineData("Season 1/S01E23-E24-E26 - The Woman.mp4", 26)]
// Four Digits seasons
- [InlineData(@"Season 2009/2009x02 blah.avi", null)]
- [InlineData(@"Season 2009/S2009x02 blah.avi", null)]
- [InlineData(@"Season 2009/S2009E02 blah.avi", null)]
- [InlineData(@"Season 2009/S2009xE02 blah.avi", null)]
- [InlineData(@"Season 2009/seriesname 2009x02 blah.avi", null)]
- [InlineData(@"Season 2009/seriesname S2009x02 blah.avi", null)]
- [InlineData(@"Season 2009/seriesname S2009E02 blah.avi", null)]
- [InlineData(@"Season 2009/seriesname S2009xE02 blah.avi", null)]
- [InlineData(@"Season 2009/Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/2009x03 - 2009x04 - 2009x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/2009x03-04-15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/Elementary - 2009x03-04-15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/2009x03-E15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/Elementary - 2009x03-E15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/2009x03 - x04 - x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/Elementary - 2009x03 - x04 - x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/2009x03x04x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/Elementary - 2009x03x04x15 - Ep Name.mp4", 15)]
- [InlineData(@"Season 2009/Elementary - S2009E23-E24-E26 - The Woman.mp4", 26)]
- [InlineData(@"Season 2009/S2009E23-E24-E26 - The Woman.mp4", 26)]
+ [InlineData("Season 2009/2009x02 blah.avi", null)]
+ [InlineData("Season 2009/S2009x02 blah.avi", null)]
+ [InlineData("Season 2009/S2009E02 blah.avi", null)]
+ [InlineData("Season 2009/S2009xE02 blah.avi", null)]
+ [InlineData("Season 2009/seriesname 2009x02 blah.avi", null)]
+ [InlineData("Season 2009/seriesname S2009x02 blah.avi", null)]
+ [InlineData("Season 2009/seriesname S2009E02 blah.avi", null)]
+ [InlineData("Season 2009/seriesname S2009xE02 blah.avi", null)]
+ [InlineData("Season 2009/Elementary - 2009x03 - 2009x04 - 2009x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/2009x03 - 2009x04 - 2009x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/2009x03-04-15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/Elementary - 2009x03-04-15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/2009x03-E15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/Elementary - 2009x03-E15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/2009x03 - x04 - x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/Elementary - 2009x03 - x04 - x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/2009x03x04x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/Elementary - 2009x03x04x15 - Ep Name.mp4", 15)]
+ [InlineData("Season 2009/Elementary - S2009E23-E24-E26 - The Woman.mp4", 26)]
+ [InlineData("Season 2009/S2009E23-E24-E26 - The Woman.mp4", 26)]
// Without season number
- [InlineData(@"Season 1/02 - blah.avi", null)]
- [InlineData(@"Season 2/02 - blah 14 blah.avi", null)]
- [InlineData(@"Season 1/02 - blah-02 a.avi", null)]
- [InlineData(@"Season 2/02.avi", null)]
- [InlineData(@"Season 1/02-03 - blah.avi", 3)]
- [InlineData(@"Season 2/02-04 - blah 14 blah.avi", 4)]
- [InlineData(@"Season 1/02-05 - blah-02 a.avi", 5)]
- [InlineData(@"Season 2/02-04.avi", 4)]
- [InlineData(@"Season 2 /[HorribleSubs] Hunter X Hunter - 136[720p].mkv", null)]
+ [InlineData("Season 1/02 - blah.avi", null)]
+ [InlineData("Season 2/02 - blah 14 blah.avi", null)]
+ [InlineData("Season 1/02 - blah-02 a.avi", null)]
+ [InlineData("Season 2/02.avi", null)]
+ [InlineData("Season 1/02-03 - blah.avi", 3)]
+ [InlineData("Season 2/02-04 - blah 14 blah.avi", 4)]
+ [InlineData("Season 1/02-05 - blah-02 a.avi", 5)]
+ [InlineData("Season 2/02-04.avi", 4)]
+ [InlineData("Season 2 /[HorribleSubs] Hunter X Hunter - 136[720p].mkv", null)]
// With format specification that must not be detected as ending episode number
- [InlineData(@"Season 1/series-s09e14-1080p.mkv", null)]
- [InlineData(@"Season 1/series-s09e14-720p.mkv", null)]
- [InlineData(@"Season 1/series-s09e14-720i.mkv", null)]
- [InlineData(@"Season 1/MOONLIGHTING_s01e01-e04.mkv", 4)]
- [InlineData(@"Season 1/MOONLIGHTING_s01e01-e04", 4)]
+ [InlineData("Season 1/series-s09e14-1080p.mkv", null)]
+ [InlineData("Season 1/series-s09e14-720p.mkv", null)]
+ [InlineData("Season 1/series-s09e14-720i.mkv", null)]
+ [InlineData("Season 1/MOONLIGHTING_s01e01-e04.mkv", 4)]
+ [InlineData("Season 1/MOONLIGHTING_s01e01-e04", 4)]
public void TestGetEndingEpisodeNumberFromFile(string filename, int? endingEpisodeNumber)
{
var result = _episodePathParser.Parse(filename, false);
diff --git a/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs b/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
index 55af33836..6773bbeb1 100644
--- a/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/SeasonFolderTests.cs
@@ -6,23 +6,23 @@ namespace Jellyfin.Naming.Tests.TV
public class SeasonFolderTests
{
[Theory]
- [InlineData(@"/Drive/Season 1", 1, true)]
- [InlineData(@"/Drive/Season 2", 2, true)]
- [InlineData(@"/Drive/Season 02", 2, true)]
- [InlineData(@"/Drive/Seinfeld/S02", 2, true)]
- [InlineData(@"/Drive/Seinfeld/2", 2, true)]
- [InlineData(@"/Drive/Season 2009", 2009, true)]
- [InlineData(@"/Drive/Season1", 1, true)]
- [InlineData(@"The Wonder Years/The.Wonder.Years.S04.PDTV.x264-JCH", 4, true)]
- [InlineData(@"/Drive/Season 7 (2016)", 7, false)]
- [InlineData(@"/Drive/Staffel 7 (2016)", 7, false)]
- [InlineData(@"/Drive/Stagione 7 (2016)", 7, false)]
- [InlineData(@"/Drive/Season (8)", null, false)]
- [InlineData(@"/Drive/3.Staffel", 3, false)]
- [InlineData(@"/Drive/s06e05", null, false)]
- [InlineData(@"/Drive/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv", null, false)]
- [InlineData(@"/Drive/extras", 0, true)]
- [InlineData(@"/Drive/specials", 0, true)]
+ [InlineData("/Drive/Season 1", 1, true)]
+ [InlineData("/Drive/Season 2", 2, true)]
+ [InlineData("/Drive/Season 02", 2, true)]
+ [InlineData("/Drive/Seinfeld/S02", 2, true)]
+ [InlineData("/Drive/Seinfeld/2", 2, true)]
+ [InlineData("/Drive/Season 2009", 2009, true)]
+ [InlineData("/Drive/Season1", 1, true)]
+ [InlineData("The Wonder Years/The.Wonder.Years.S04.PDTV.x264-JCH", 4, true)]
+ [InlineData("/Drive/Season 7 (2016)", 7, false)]
+ [InlineData("/Drive/Staffel 7 (2016)", 7, false)]
+ [InlineData("/Drive/Stagione 7 (2016)", 7, false)]
+ [InlineData("/Drive/Season (8)", null, false)]
+ [InlineData("/Drive/3.Staffel", 3, false)]
+ [InlineData("/Drive/s06e05", null, false)]
+ [InlineData("/Drive/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv", null, false)]
+ [InlineData("/Drive/extras", 0, true)]
+ [InlineData("/Drive/specials", 0, true)]
public void GetSeasonNumberFromPathTest(string path, int? seasonNumber, bool isSeasonDirectory)
{
var result = SeasonPathParser.Parse(path, true, true);
diff --git a/tests/Jellyfin.Naming.Tests/TV/SeasonNumberTests.cs b/tests/Jellyfin.Naming.Tests/TV/SeasonNumberTests.cs
index 58ec1b5d2..94a953de3 100644
--- a/tests/Jellyfin.Naming.Tests/TV/SeasonNumberTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/SeasonNumberTests.cs
@@ -51,8 +51,8 @@ namespace Jellyfin.Naming.Tests.TV
[InlineData("Season 2009/Elementary - S2009E23-E24-E26 - The Woman.mp4", 2009)]
[InlineData("Season 2009/S2009E23-E24-E26 - The Woman.mp4", 2009)]
[InlineData("Series/1-12 - The Woman.mp4", 1)]
- [InlineData(@"Running Man/Running Man S2017E368.mkv", 2017)]
- [InlineData(@"Case Closed (1996-2007)/Case Closed - 317.mkv", 3)]
+ [InlineData("Running Man/Running Man S2017E368.mkv", 2017)]
+ [InlineData("Case Closed (1996-2007)/Case Closed - 317.mkv", 3)]
// TODO: [InlineData(@"Seinfeld/Seinfeld 0807 The Checks.avi", 8)]
public void GetSeasonNumberFromEpisodeFileTest(string path, int? expected)
{
diff --git a/tests/Jellyfin.Naming.Tests/TV/SimpleEpisodeTests.cs b/tests/Jellyfin.Naming.Tests/TV/SimpleEpisodeTests.cs
index fa46ecc3a..3721cd28c 100644
--- a/tests/Jellyfin.Naming.Tests/TV/SimpleEpisodeTests.cs
+++ b/tests/Jellyfin.Naming.Tests/TV/SimpleEpisodeTests.cs
@@ -21,8 +21,8 @@ namespace Jellyfin.Naming.Tests.TV
[InlineData("Series/4x12 - The Woman.mp4", "", 4, 12)]
[InlineData("Series/LA X, Pt. 1_s06e32.mp4", "LA X, Pt. 1", 6, 32)]
[InlineData("[Baz-Bar]Foo - [1080p][Multiple Subtitle]/[Baz-Bar] Foo - 05 [1080p][Multiple Subtitle].mkv", "Foo", null, 5)]
- [InlineData(@"/Foo/The.Series.Name.S01E04.WEBRip.x264-Baz[Bar]/the.series.name.s01e04.webrip.x264-Baz[Bar].mkv", "The.Series.Name", 1, 4)]
- [InlineData(@"Love.Death.and.Robots.S01.1080p.NF.WEB-DL.DDP5.1.x264-NTG/Love.Death.and.Robots.S01E01.Sonnies.Edge.1080p.NF.WEB-DL.DDP5.1.x264-NTG.mkv", "Love.Death.and.Robots", 1, 1)]
+ [InlineData("/Foo/The.Series.Name.S01E04.WEBRip.x264-Baz[Bar]/the.series.name.s01e04.webrip.x264-Baz[Bar].mkv", "The.Series.Name", 1, 4)]
+ [InlineData("Love.Death.and.Robots.S01.1080p.NF.WEB-DL.DDP5.1.x264-NTG/Love.Death.and.Robots.S01E01.Sonnies.Edge.1080p.NF.WEB-DL.DDP5.1.x264-NTG.mkv", "Love.Death.and.Robots", 1, 1)]
[InlineData("[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken/[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken - 12 (NVENC H.265 1080p).mkv", "Tensura Nikki - Tensei Shitara Slime Datta Ken", null, 12)]
[InlineData("[Baz-Bar]Foo - 01 - 12[1080p][Multiple Subtitle]/[Baz-Bar] Foo - 05 [1080p][Multiple Subtitle].mkv", "Foo", null, 5)]
[InlineData("Series/4-12 - The Woman.mp4", "", 4, 12, 12)]
diff --git a/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs b/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
index b1141df47..62d60e5a4 100644
--- a/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs
@@ -10,34 +10,34 @@ namespace Jellyfin.Naming.Tests.Video
private readonly NamingOptions _namingOptions = new NamingOptions();
[Theory]
- [InlineData(@"The Wolf of Wall Street (2013).mkv", "The Wolf of Wall Street", 2013)]
- [InlineData(@"The Wolf of Wall Street 2 (2013).mkv", "The Wolf of Wall Street 2", 2013)]
- [InlineData(@"The Wolf of Wall Street - 2 (2013).mkv", "The Wolf of Wall Street - 2", 2013)]
- [InlineData(@"The Wolf of Wall Street 2001 (2013).mkv", "The Wolf of Wall Street 2001", 2013)]
- [InlineData(@"300 (2006).mkv", "300", 2006)]
- [InlineData(@"d:/movies/300 (2006).mkv", "300", 2006)]
- [InlineData(@"300 2 (2006).mkv", "300 2", 2006)]
- [InlineData(@"300 - 2 (2006).mkv", "300 - 2", 2006)]
- [InlineData(@"300 2001 (2006).mkv", "300 2001", 2006)]
- [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", "curse.of.chucky", 2013)]
- [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.2160p.bluray.x264-rough", "curse.of.chucky", 2013)]
- [InlineData(@"/server/Movies/300 (2007)/300 (2006).bluray.disc", "300", 2006)]
- [InlineData(@"Arrival.2016.2160p.Blu-Ray.HEVC.mkv", "Arrival", 2016)]
- [InlineData(@"The Wolf of Wall Street (2013)", "The Wolf of Wall Street", 2013)]
- [InlineData(@"The Wolf of Wall Street 2 (2013)", "The Wolf of Wall Street 2", 2013)]
- [InlineData(@"The Wolf of Wall Street - 2 (2013)", "The Wolf of Wall Street - 2", 2013)]
- [InlineData(@"The Wolf of Wall Street 2001 (2013)", "The Wolf of Wall Street 2001", 2013)]
- [InlineData(@"300 (2006)", "300", 2006)]
- [InlineData(@"d:/movies/300 (2006)", "300", 2006)]
- [InlineData(@"300 2 (2006)", "300 2", 2006)]
- [InlineData(@"300 - 2 (2006)", "300 - 2", 2006)]
- [InlineData(@"300 2001 (2006)", "300 2001", 2006)]
- [InlineData(@"/server/Movies/300 (2007)/300 (2006)", "300", 2006)]
- [InlineData(@"/server/Movies/300 (2007)/300 (2006).mkv", "300", 2006)]
- [InlineData(@"American.Psycho.mkv", "American.Psycho.mkv", null)]
- [InlineData(@"American Psycho.mkv", "American Psycho.mkv", null)]
- [InlineData(@"[rec].mkv", "[rec].mkv", null)]
- [InlineData(@"St. Vincent (2014)", "St. Vincent", 2014)]
+ [InlineData("The Wolf of Wall Street (2013).mkv", "The Wolf of Wall Street", 2013)]
+ [InlineData("The Wolf of Wall Street 2 (2013).mkv", "The Wolf of Wall Street 2", 2013)]
+ [InlineData("The Wolf of Wall Street - 2 (2013).mkv", "The Wolf of Wall Street - 2", 2013)]
+ [InlineData("The Wolf of Wall Street 2001 (2013).mkv", "The Wolf of Wall Street 2001", 2013)]
+ [InlineData("300 (2006).mkv", "300", 2006)]
+ [InlineData("d:/movies/300 (2006).mkv", "300", 2006)]
+ [InlineData("300 2 (2006).mkv", "300 2", 2006)]
+ [InlineData("300 - 2 (2006).mkv", "300 - 2", 2006)]
+ [InlineData("300 2001 (2006).mkv", "300 2001", 2006)]
+ [InlineData("curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", "curse.of.chucky", 2013)]
+ [InlineData("curse.of.chucky.2013.stv.unrated.multi.2160p.bluray.x264-rough", "curse.of.chucky", 2013)]
+ [InlineData("/server/Movies/300 (2007)/300 (2006).bluray.disc", "300", 2006)]
+ [InlineData("Arrival.2016.2160p.Blu-Ray.HEVC.mkv", "Arrival", 2016)]
+ [InlineData("The Wolf of Wall Street (2013)", "The Wolf of Wall Street", 2013)]
+ [InlineData("The Wolf of Wall Street 2 (2013)", "The Wolf of Wall Street 2", 2013)]
+ [InlineData("The Wolf of Wall Street - 2 (2013)", "The Wolf of Wall Street - 2", 2013)]
+ [InlineData("The Wolf of Wall Street 2001 (2013)", "The Wolf of Wall Street 2001", 2013)]
+ [InlineData("300 (2006)", "300", 2006)]
+ [InlineData("d:/movies/300 (2006)", "300", 2006)]
+ [InlineData("300 2 (2006)", "300 2", 2006)]
+ [InlineData("300 - 2 (2006)", "300 - 2", 2006)]
+ [InlineData("300 2001 (2006)", "300 2001", 2006)]
+ [InlineData("/server/Movies/300 (2007)/300 (2006)", "300", 2006)]
+ [InlineData("/server/Movies/300 (2007)/300 (2006).mkv", "300", 2006)]
+ [InlineData("American.Psycho.mkv", "American.Psycho.mkv", null)]
+ [InlineData("American Psycho.mkv", "American Psycho.mkv", null)]
+ [InlineData("[rec].mkv", "[rec].mkv", null)]
+ [InlineData("St. Vincent (2014)", "St. Vincent", 2014)]
[InlineData("Super movie(2009).mp4", "Super movie", 2009)]
[InlineData("Drug War 2013.mp4", "Drug War", 2013)]
[InlineData("My Movie (1997) - GreatestReleaseGroup 2019.mp4", "My Movie", 1997)]
@@ -45,9 +45,9 @@ namespace Jellyfin.Naming.Tests.Video
[InlineData("First Man (2018) 1080p.mkv", "First Man", 2018)]
[InlineData("Maximum Ride - 2016 - WEBDL-1080p - x264 AC3.mkv", "Maximum Ride", 2016)]
// FIXME: [InlineData("Robin Hood [Multi-Subs] [2018].mkv", "Robin Hood", 2018)]
- [InlineData(@"3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014)] // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
+ [InlineData("3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014)] // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
[InlineData("3 days to kill (2005).mkv", "3 days to kill", 2005)]
- [InlineData(@"Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - Ozlem.mp4", "Rain Man", 1988)]
+ [InlineData("Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - Ozlem.mp4", "Rain Man", 1988)]
[InlineData("My Movie 2013.12.09", "My Movie 2013.12.09", null)]
[InlineData("My Movie 2013-12-09", "My Movie 2013-12-09", null)]
[InlineData("My Movie 20131209", "My Movie 20131209", null)]
diff --git a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
index 511a014a6..fccce5bff 100644
--- a/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs
@@ -22,7 +22,7 @@ namespace Jellyfin.Naming.Tests.Video
[Fact]
public void Test3DName()
{
- var result = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
+ var result = VideoResolver.ResolveFile("C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
Assert.Equal("hsbs", result?.Format3D);
Assert.Equal("Oblivion", result?.Name);
diff --git a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
index 294f11ee7..183ec8984 100644
--- a/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/MultiVersionTests.cs
@@ -15,10 +15,10 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past - 1080p.mkv",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past-trailer.mp4",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past - [hsbs].mkv",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past [hsbs].mkv"
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past - 1080p.mkv",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past-trailer.mp4",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past - [hsbs].mkv",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past [hsbs].mkv"
};
var result = VideoListResolver.Resolve(
@@ -34,10 +34,10 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past - apple.mkv",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past-trailer.mp4",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past - banana.mkv",
- @"/movies/X-Men Days of Future Past/X-Men Days of Future Past [banana].mp4"
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past - apple.mkv",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past-trailer.mp4",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past - banana.mkv",
+ "/movies/X-Men Days of Future Past/X-Men Days of Future Past [banana].mp4"
};
var result = VideoListResolver.Resolve(
@@ -54,8 +54,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1925 version.mkv",
- @"/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1929 version.mkv"
+ "/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1925 version.mkv",
+ "/movies/The Phantom of the Opera (1925)/The Phantom of the Opera (1925) - 1929 version.mkv"
};
var result = VideoListResolver.Resolve(
@@ -71,13 +71,13 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/M/Movie 1.mkv",
- @"/movies/M/Movie 2.mkv",
- @"/movies/M/Movie 3.mkv",
- @"/movies/M/Movie 4.mkv",
- @"/movies/M/Movie 5.mkv",
- @"/movies/M/Movie 6.mkv",
- @"/movies/M/Movie 7.mkv"
+ "/movies/M/Movie 1.mkv",
+ "/movies/M/Movie 2.mkv",
+ "/movies/M/Movie 3.mkv",
+ "/movies/M/Movie 4.mkv",
+ "/movies/M/Movie 5.mkv",
+ "/movies/M/Movie 6.mkv",
+ "/movies/M/Movie 7.mkv"
};
var result = VideoListResolver.Resolve(
@@ -93,14 +93,14 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Movie/Movie.mkv",
- @"/movies/Movie/Movie-2.mkv",
- @"/movies/Movie/Movie-3.mkv",
- @"/movies/Movie/Movie-4.mkv",
- @"/movies/Movie/Movie-5.mkv",
- @"/movies/Movie/Movie-6.mkv",
- @"/movies/Movie/Movie-7.mkv",
- @"/movies/Movie/Movie-8.mkv"
+ "/movies/Movie/Movie.mkv",
+ "/movies/Movie/Movie-2.mkv",
+ "/movies/Movie/Movie-3.mkv",
+ "/movies/Movie/Movie-4.mkv",
+ "/movies/Movie/Movie-5.mkv",
+ "/movies/Movie/Movie-6.mkv",
+ "/movies/Movie/Movie-7.mkv",
+ "/movies/Movie/Movie-8.mkv"
};
var result = VideoListResolver.Resolve(
@@ -116,15 +116,15 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Mo/Movie 1.mkv",
- @"/movies/Mo/Movie 2.mkv",
- @"/movies/Mo/Movie 3.mkv",
- @"/movies/Mo/Movie 4.mkv",
- @"/movies/Mo/Movie 5.mkv",
- @"/movies/Mo/Movie 6.mkv",
- @"/movies/Mo/Movie 7.mkv",
- @"/movies/Mo/Movie 8.mkv",
- @"/movies/Mo/Movie 9.mkv"
+ "/movies/Mo/Movie 1.mkv",
+ "/movies/Mo/Movie 2.mkv",
+ "/movies/Mo/Movie 3.mkv",
+ "/movies/Mo/Movie 4.mkv",
+ "/movies/Mo/Movie 5.mkv",
+ "/movies/Mo/Movie 6.mkv",
+ "/movies/Mo/Movie 7.mkv",
+ "/movies/Mo/Movie 8.mkv",
+ "/movies/Mo/Movie 9.mkv"
};
var result = VideoListResolver.Resolve(
@@ -140,11 +140,11 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Movie/Movie 1.mkv",
- @"/movies/Movie/Movie 2.mkv",
- @"/movies/Movie/Movie 3.mkv",
- @"/movies/Movie/Movie 4.mkv",
- @"/movies/Movie/Movie 5.mkv"
+ "/movies/Movie/Movie 1.mkv",
+ "/movies/Movie/Movie 2.mkv",
+ "/movies/Movie/Movie 3.mkv",
+ "/movies/Movie/Movie 4.mkv",
+ "/movies/Movie/Movie 5.mkv"
};
var result = VideoListResolver.Resolve(
@@ -162,11 +162,11 @@ namespace Jellyfin.Naming.Tests.Video
var files = new[]
{
- @"/movies/Iron Man/Iron Man.mkv",
- @"/movies/Iron Man/Iron Man (2008).mkv",
- @"/movies/Iron Man/Iron Man (2009).mkv",
- @"/movies/Iron Man/Iron Man (2010).mkv",
- @"/movies/Iron Man/Iron Man (2011).mkv"
+ "/movies/Iron Man/Iron Man.mkv",
+ "/movies/Iron Man/Iron Man (2008).mkv",
+ "/movies/Iron Man/Iron Man (2009).mkv",
+ "/movies/Iron Man/Iron Man (2010).mkv",
+ "/movies/Iron Man/Iron Man (2011).mkv"
};
var result = VideoListResolver.Resolve(
@@ -182,13 +182,13 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Iron Man/Iron Man.mkv",
- @"/movies/Iron Man/Iron Man-720p.mkv",
- @"/movies/Iron Man/Iron Man-test.mkv",
- @"/movies/Iron Man/Iron Man-bluray.mkv",
- @"/movies/Iron Man/Iron Man-3d.mkv",
- @"/movies/Iron Man/Iron Man-3d-hsbs.mkv",
- @"/movies/Iron Man/Iron Man[test].mkv"
+ "/movies/Iron Man/Iron Man.mkv",
+ "/movies/Iron Man/Iron Man-720p.mkv",
+ "/movies/Iron Man/Iron Man-test.mkv",
+ "/movies/Iron Man/Iron Man-bluray.mkv",
+ "/movies/Iron Man/Iron Man-3d.mkv",
+ "/movies/Iron Man/Iron Man-3d-hsbs.mkv",
+ "/movies/Iron Man/Iron Man[test].mkv"
};
var result = VideoListResolver.Resolve(
@@ -211,13 +211,13 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Iron Man/Iron Man.mkv",
- @"/movies/Iron Man/Iron Man - 720p.mkv",
- @"/movies/Iron Man/Iron Man - test.mkv",
- @"/movies/Iron Man/Iron Man - bluray.mkv",
- @"/movies/Iron Man/Iron Man - 3d.mkv",
- @"/movies/Iron Man/Iron Man - 3d-hsbs.mkv",
- @"/movies/Iron Man/Iron Man [test].mkv"
+ "/movies/Iron Man/Iron Man.mkv",
+ "/movies/Iron Man/Iron Man - 720p.mkv",
+ "/movies/Iron Man/Iron Man - test.mkv",
+ "/movies/Iron Man/Iron Man - bluray.mkv",
+ "/movies/Iron Man/Iron Man - 3d.mkv",
+ "/movies/Iron Man/Iron Man - 3d-hsbs.mkv",
+ "/movies/Iron Man/Iron Man [test].mkv"
};
var result = VideoListResolver.Resolve(
@@ -240,8 +240,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Iron Man/Iron Man - B (2006).mkv",
- @"/movies/Iron Man/Iron Man - C (2007).mkv"
+ "/movies/Iron Man/Iron Man - B (2006).mkv",
+ "/movies/Iron Man/Iron Man - C (2007).mkv"
};
var result = VideoListResolver.Resolve(
@@ -256,13 +256,13 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Iron Man/Iron Man.mkv",
- @"/movies/Iron Man/Iron Man_720p.mkv",
- @"/movies/Iron Man/Iron Man_test.mkv",
- @"/movies/Iron Man/Iron Man_bluray.mkv",
- @"/movies/Iron Man/Iron Man_3d.mkv",
- @"/movies/Iron Man/Iron Man_3d-hsbs.mkv",
- @"/movies/Iron Man/Iron Man_3d.hsbs.mkv"
+ "/movies/Iron Man/Iron Man.mkv",
+ "/movies/Iron Man/Iron Man_720p.mkv",
+ "/movies/Iron Man/Iron Man_test.mkv",
+ "/movies/Iron Man/Iron Man_bluray.mkv",
+ "/movies/Iron Man/Iron Man_3d.mkv",
+ "/movies/Iron Man/Iron Man_3d-hsbs.mkv",
+ "/movies/Iron Man/Iron Man_3d.hsbs.mkv"
};
var result = VideoListResolver.Resolve(
@@ -280,11 +280,11 @@ namespace Jellyfin.Naming.Tests.Video
var files = new[]
{
- @"/movies/Iron Man/Iron Man (2007).mkv",
- @"/movies/Iron Man/Iron Man (2008).mkv",
- @"/movies/Iron Man/Iron Man (2009).mkv",
- @"/movies/Iron Man/Iron Man (2010).mkv",
- @"/movies/Iron Man/Iron Man (2011).mkv"
+ "/movies/Iron Man/Iron Man (2007).mkv",
+ "/movies/Iron Man/Iron Man (2008).mkv",
+ "/movies/Iron Man/Iron Man (2009).mkv",
+ "/movies/Iron Man/Iron Man (2010).mkv",
+ "/movies/Iron Man/Iron Man (2011).mkv"
};
var result = VideoListResolver.Resolve(
@@ -300,8 +300,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/Blade Runner (1982)/Blade Runner (1982) [Final Cut] [1080p HEVC AAC].mkv",
- @"/movies/Blade Runner (1982)/Blade Runner (1982) [EE by ADM] [480p HEVC AAC,AAC,AAC].mkv"
+ "/movies/Blade Runner (1982)/Blade Runner (1982) [Final Cut] [1080p HEVC AAC].mkv",
+ "/movies/Blade Runner (1982)/Blade Runner (1982) [EE by ADM] [480p HEVC AAC,AAC,AAC].mkv"
};
var result = VideoListResolver.Resolve(
@@ -317,8 +317,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [1080p] Blu-ray.x264.DTS.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [2160p] Blu-ray.x265.AAC.mkv"
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [1080p] Blu-ray.x264.DTS.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) [2160p] Blu-ray.x265.AAC.mkv"
};
var result = VideoListResolver.Resolve(
@@ -334,12 +334,12 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Theatrical Release.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Directors Cut.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 1080p.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 2160p.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 720p.mkv",
- @"/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016).mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Theatrical Release.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - Directors Cut.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 1080p.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 2160p.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016) - 720p.mkv",
+ "/movies/X-Men Apocalypse (2016)/X-Men Apocalypse (2016).mkv",
};
var result = VideoListResolver.Resolve(
@@ -361,8 +361,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 1.mkv",
- @"/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 2.mkv"
+ "/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 1.mkv",
+ "/movies/John Wick - Kapitel 3 (2019) [imdbid=tt6146586]/John Wick - Kapitel 3 (2019) [imdbid=tt6146586] - Version 2.mkv"
};
var result = VideoListResolver.Resolve(
@@ -378,8 +378,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 1].mkv",
- @"/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 2.mkv"
+ "/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 1].mkv",
+ "/movies/John Wick - Chapter 3 (2019)/John Wick - Chapter 3 (2019) [Version 2.mkv"
};
var result = VideoListResolver.Resolve(
diff --git a/tests/Jellyfin.Naming.Tests/Video/StackTests.cs b/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
index 97b52f749..c95703f53 100644
--- a/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/StackTests.cs
@@ -384,8 +384,8 @@ namespace Jellyfin.Naming.Tests.Video
// No stacking here because there is no part/disc/etc
var files = new[]
{
- @"M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 01)",
- @"M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 02)"
+ "M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 01)",
+ "M:/Movies (DVD)/Movies (Musical)/The Sound of Music/The Sound of Music (1965) (Disc 02)"
};
var result = StackResolver.ResolveDirectories(files, _namingOptions).ToList();
diff --git a/tests/Jellyfin.Naming.Tests/Video/StubTests.cs b/tests/Jellyfin.Naming.Tests/Video/StubTests.cs
index 1d50df7a6..fc852ae85 100644
--- a/tests/Jellyfin.Naming.Tests/Video/StubTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/StubTests.cs
@@ -29,7 +29,7 @@ namespace Jellyfin.Naming.Tests.Video
[Fact]
public void TestStubName()
{
- var result = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc", _namingOptions);
+ var result = VideoResolver.ResolveFile("C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc", _namingOptions);
Assert.Equal("Oblivion", result?.Name);
}
diff --git a/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs b/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs
index 0316377d4..377f82eac 100644
--- a/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/VideoListResolverTests.cs
@@ -200,8 +200,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 1",
- @"M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 2"
+ "M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 1",
+ "M:/Movies (DVD)/Movies (Musical)/Sound of Music (1965)/Sound of Music Disc 2"
};
var result = VideoListResolver.Resolve(
@@ -217,8 +217,8 @@ namespace Jellyfin.Naming.Tests.Video
// These should be considered separate, unrelated videos
var files = new[]
{
- @"My movie #1.mp4",
- @"My movie #2.mp4"
+ "My movie #1.mp4",
+ "My movie #2.mp4"
};
var result = VideoListResolver.Resolve(
@@ -233,10 +233,10 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"No (2012) part1.mp4",
- @"No (2012) part2.mp4",
- @"No (2012) part1-trailer.mp4",
- @"No (2012)-trailer.mp4"
+ "No (2012) part1.mp4",
+ "No (2012) part2.mp4",
+ "No (2012) part1-trailer.mp4",
+ "No (2012)-trailer.mp4"
};
var result = VideoListResolver.Resolve(
@@ -254,10 +254,10 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/Movies/Top Gun (1984)/movie.mp4",
- @"/Movies/Top Gun (1984)/Top Gun (1984)-trailer.mp4",
- @"/Movies/Top Gun (1984)/Top Gun (1984)-trailer2.mp4",
- @"/Movies/trailer.mp4"
+ "/Movies/Top Gun (1984)/movie.mp4",
+ "/Movies/Top Gun (1984)/Top Gun (1984)-trailer.mp4",
+ "/Movies/Top Gun (1984)/Top Gun (1984)-trailer2.mp4",
+ "/Movies/trailer.mp4"
};
var result = VideoListResolver.Resolve(
@@ -276,10 +276,10 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd1.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd2.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd1.avi",
- @"/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd2.avi"
+ "/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd1.avi",
+ "/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Counterfeit Racks (2011) Disc 1 cd2.avi",
+ "/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd1.avi",
+ "/MCFAMILY-PC/Private3$/Heterosexual/Breast In Class 2 Counterfeit Racks (2011)/Breast In Class 2 Disc 2 cd2.avi"
};
var result = VideoListResolver.Resolve(
@@ -294,7 +294,7 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/nas-markrobbo78/Videos/INDEX HTPC/Movies/Watched/3 - ACTION/Argo (2012)/movie.mkv"
+ "/nas-markrobbo78/Videos/INDEX HTPC/Movies/Watched/3 - ACTION/Argo (2012)/movie.mkv"
};
var result = VideoListResolver.Resolve(
@@ -309,7 +309,7 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"The Colony.mkv"
+ "The Colony.mkv"
};
var result = VideoListResolver.Resolve(
@@ -324,8 +324,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"Four Sisters and a Wedding - A.avi",
- @"Four Sisters and a Wedding - B.avi"
+ "Four Sisters and a Wedding - A.avi",
+ "Four Sisters and a Wedding - B.avi"
};
var result = VideoListResolver.Resolve(
@@ -342,8 +342,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"Four Rooms - A.avi",
- @"Four Rooms - A.mp4"
+ "Four Rooms - A.avi",
+ "Four Rooms - A.mp4"
};
var result = VideoListResolver.Resolve(
@@ -358,8 +358,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/Server/Despicable Me/Despicable Me (2010).mkv",
- @"/Server/Despicable Me/trailer.mkv"
+ "/Server/Despicable Me/Despicable Me (2010).mkv",
+ "/Server/Despicable Me/trailer.mkv"
};
var result = VideoListResolver.Resolve(
@@ -376,8 +376,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/Server/Despicable Me/Despicable Me (2010).mkv",
- @"/Server/Despicable Me/trailers/some title.mkv"
+ "/Server/Despicable Me/Despicable Me (2010).mkv",
+ "/Server/Despicable Me/trailers/some title.mkv"
};
var result = VideoListResolver.Resolve(
@@ -394,8 +394,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
- @"/Movies/Despicable Me/Despicable Me.mkv",
- @"/Movies/Despicable Me/trailers/trailer.mkv"
+ "/Movies/Despicable Me/Despicable Me.mkv",
+ "/Movies/Despicable Me/trailers/trailer.mkv"
};
var result = VideoListResolver.Resolve(
diff --git a/tests/Jellyfin.Naming.Tests/Video/VideoResolverTests.cs b/tests/Jellyfin.Naming.Tests/Video/VideoResolverTests.cs
index 33a99e107..8455a56a1 100644
--- a/tests/Jellyfin.Naming.Tests/Video/VideoResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/Video/VideoResolverTests.cs
@@ -15,26 +15,26 @@ namespace Jellyfin.Naming.Tests.Video
var data = new TheoryData<VideoFileInfo>();
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
+ path: "/server/Movies/7 Psychos.mkv/7 Psychos.mkv",
container: "mkv",
name: "7 Psychos"));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
+ path: "/server/Movies/3 days to kill (2005)/3 days to kill (2005).mkv",
container: "mkv",
name: "3 days to kill",
year: 2005));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/American Psycho/American.Psycho.mkv",
+ path: "/server/Movies/American Psycho/American.Psycho.mkv",
container: "mkv",
name: "American.Psycho"));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
+ path: "/server/Movies/brave (2007)/brave (2006).3d.sbs.mkv",
container: "mkv",
name: "brave",
year: 2006,
@@ -43,14 +43,14 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
+ path: "/server/Movies/300 (2007)/300 (2006).3d1.sbas.mkv",
container: "mkv",
name: "300",
year: 2006));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
+ path: "/server/Movies/300 (2007)/300 (2006).3d.sbs.mkv",
container: "mkv",
name: "300",
year: 2006,
@@ -59,7 +59,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
+ path: "/server/Movies/brave (2007)/brave (2006)-trailer.bluray.disc",
container: "disc",
name: "brave",
year: 2006,
@@ -68,7 +68,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
+ path: "/server/Movies/300 (2007)/300 (2006)-trailer.bluray.disc",
container: "disc",
name: "300",
year: 2006,
@@ -77,7 +77,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
+ path: "/server/Movies/Brave (2007)/Brave (2006).bluray.disc",
container: "disc",
name: "Brave",
year: 2006,
@@ -86,7 +86,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006).bluray.disc",
+ path: "/server/Movies/300 (2007)/300 (2006).bluray.disc",
container: "disc",
name: "300",
year: 2006,
@@ -95,7 +95,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
+ path: "/server/Movies/300 (2007)/300 (2006)-trailer.mkv",
container: "mkv",
name: "300",
year: 2006,
@@ -103,7 +103,7 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
+ path: "/server/Movies/Brave (2007)/Brave (2006)-trailer.mkv",
container: "mkv",
name: "Brave",
year: 2006,
@@ -111,28 +111,28 @@ namespace Jellyfin.Naming.Tests.Video
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/300 (2007)/300 (2006).mkv",
+ path: "/server/Movies/300 (2007)/300 (2006).mkv",
container: "mkv",
name: "300",
year: 2006));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
+ path: "/server/Movies/Bad Boys (1995)/Bad Boys (1995).mkv",
container: "mkv",
name: "Bad Boys",
year: 1995));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/Brave (2007)/Brave (2006).mkv",
+ path: "/server/Movies/Brave (2007)/Brave (2006).mkv",
container: "mkv",
name: "Brave",
year: 2006));
data.Add(
new VideoFileInfo(
- path: @"/server/Movies/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF.mp4",
+ path: "/server/Movies/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF/Rain Man 1988 REMASTERED 1080p BluRay x264 AAC - JEFF.mp4",
container: "mp4",
name: "Rain Man",
year: 1988));
@@ -174,8 +174,8 @@ namespace Jellyfin.Naming.Tests.Video
{
var paths = new[]
{
- @"/Server/Iron Man",
- @"Batman",
+ "/Server/Iron Man",
+ "Batman",
string.Empty
};
diff --git a/tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs b/tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs
index a78b872df..30726f1d3 100644
--- a/tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs
+++ b/tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs
@@ -1,4 +1,4 @@
-using Jellyfin.Networking.Configuration;
+using MediaBrowser.Common.Net;
using Xunit;
namespace Jellyfin.Networking.Tests.Configuration;
diff --git a/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj b/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
index 3747db3bb..2d7f11210 100644
--- a/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
+++ b/tests/Jellyfin.Networking.Tests/Jellyfin.Networking.Tests.csproj
@@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
- <ProjectReference Include="../../Jellyfin.Networking/Jellyfin.Networking.csproj" />
+ <ProjectReference Include="../../src/Jellyfin.Networking/Jellyfin.Networking.csproj" />
</ItemGroup>
</Project>
diff --git a/tests/Jellyfin.Networking.Tests/NetworkExtensionsTests.cs b/tests/Jellyfin.Networking.Tests/NetworkExtensionsTests.cs
index 072e0a8c5..01546aa2b 100644
--- a/tests/Jellyfin.Networking.Tests/NetworkExtensionsTests.cs
+++ b/tests/Jellyfin.Networking.Tests/NetworkExtensionsTests.cs
@@ -1,6 +1,6 @@
using FsCheck;
using FsCheck.Xunit;
-using Jellyfin.Networking.Extensions;
+using MediaBrowser.Common.Net;
using Xunit;
namespace Jellyfin.Networking.Tests
@@ -26,15 +26,15 @@ namespace Jellyfin.Networking.Tests
[InlineData("192.168.1.2/255.255.255.0")]
[InlineData("192.168.1.2/24")]
public static void TryParse_ValidHostStrings_True(string address)
- => Assert.True(NetworkExtensions.TryParseHost(address, out _, true, true));
+ => Assert.True(NetworkUtils.TryParseHost(address, out _, true, true));
[Property]
public static Property TryParse_IPv4Address_True(IPv4Address address)
- => NetworkExtensions.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
+ => NetworkUtils.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
[Property]
public static Property TryParse_IPv6Address_True(IPv6Address address)
- => NetworkExtensions.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
+ => NetworkUtils.TryParseHost(address.Item.ToString(), out _, true, true).ToProperty();
/// <summary>
/// All should be invalid address strings.
@@ -47,6 +47,6 @@ namespace Jellyfin.Networking.Tests
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
public static void TryParse_InvalidAddressString_False(string address)
- => Assert.False(NetworkExtensions.TryParseHost(address, out _, true, true));
+ => Assert.False(NetworkUtils.TryParseHost(address, out _, true, true));
}
}
diff --git a/tests/Jellyfin.Networking.Tests/NetworkManagerTests.cs b/tests/Jellyfin.Networking.Tests/NetworkManagerTests.cs
index 2302f90b8..0333d98e6 100644
--- a/tests/Jellyfin.Networking.Tests/NetworkManagerTests.cs
+++ b/tests/Jellyfin.Networking.Tests/NetworkManagerTests.cs
@@ -1,6 +1,6 @@
using System.Net;
-using Jellyfin.Networking.Configuration;
using Jellyfin.Networking.Manager;
+using MediaBrowser.Common.Net;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
diff --git a/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs b/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs
index 022b8a3d0..3b7c43100 100644
--- a/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs
+++ b/tests/Jellyfin.Networking.Tests/NetworkParseTests.cs
@@ -2,15 +2,15 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
-using Jellyfin.Networking.Configuration;
-using Jellyfin.Networking.Extensions;
using Jellyfin.Networking.Manager;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using MediaBrowser.Model.Net;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;
+using IConfigurationManager = MediaBrowser.Common.Configuration.IConfigurationManager;
namespace Jellyfin.Networking.Tests
{
@@ -71,7 +71,6 @@ namespace Jellyfin.Networking.Tests
[InlineData("127.0.0.1/8")]
[InlineData("192.168.1.2")]
[InlineData("192.168.1.2/24")]
- [InlineData("192.168.1.2/255.255.255.0")]
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517")]
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517]")]
[InlineData("fe80::7add:12ff:febb:c67b%16")]
@@ -80,7 +79,7 @@ namespace Jellyfin.Networking.Tests
[InlineData("[fe80::7add:12ff:febb:c67b%16]")]
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517/56")]
public static void TryParseValidIPStringsTrue(string address)
- => Assert.True(NetworkExtensions.TryParseToSubnet(address, out _));
+ => Assert.True(NetworkUtils.TryParseToSubnet(address, out _));
/// <summary>
/// Checks invalid IP address formats.
@@ -93,7 +92,7 @@ namespace Jellyfin.Networking.Tests
[InlineData("fd23:184f:2029:0:3139:7386:67d7:d517:1231")]
[InlineData("[fd23:184f:2029:0:3139:7386:67d7:d517:1231]")]
public static void TryParseInvalidIPStringsFalse(string address)
- => Assert.False(NetworkExtensions.TryParseToSubnet(address, out _));
+ => Assert.False(NetworkUtils.TryParseToSubnet(address, out _));
/// <summary>
/// Checks if IPv4 address is within a defined subnet.
@@ -103,17 +102,15 @@ namespace Jellyfin.Networking.Tests
[Theory]
[InlineData("192.168.5.85/24", "192.168.5.1")]
[InlineData("192.168.5.85/24", "192.168.5.254")]
- [InlineData("192.168.5.85/255.255.255.0", "192.168.5.254")]
[InlineData("10.128.240.50/30", "10.128.240.48")]
[InlineData("10.128.240.50/30", "10.128.240.49")]
[InlineData("10.128.240.50/30", "10.128.240.50")]
[InlineData("10.128.240.50/30", "10.128.240.51")]
- [InlineData("10.128.240.50/255.255.255.252", "10.128.240.51")]
[InlineData("127.0.0.1/8", "127.0.0.1")]
public void IPv4SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
{
var ipa = IPAddress.Parse(ipAddress);
- Assert.True(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
+ Assert.True(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
}
/// <summary>
@@ -124,16 +121,14 @@ namespace Jellyfin.Networking.Tests
[Theory]
[InlineData("192.168.5.85/24", "192.168.4.254")]
[InlineData("192.168.5.85/24", "191.168.5.254")]
- [InlineData("192.168.5.85/255.255.255.252", "192.168.4.254")]
[InlineData("10.128.240.50/30", "10.128.240.47")]
[InlineData("10.128.240.50/30", "10.128.240.52")]
[InlineData("10.128.240.50/30", "10.128.239.50")]
[InlineData("10.128.240.50/30", "10.127.240.51")]
- [InlineData("10.128.240.50/255.255.255.252", "10.127.240.51")]
public void IPv4SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
{
var ipa = IPAddress.Parse(ipAddress);
- Assert.False(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
+ Assert.False(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
}
/// <summary>
@@ -149,7 +144,7 @@ namespace Jellyfin.Networking.Tests
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0000")]
public void IPv6SubnetMaskMatchesValidIPAddress(string netMask, string ipAddress)
{
- Assert.True(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
+ Assert.True(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
}
[Theory]
@@ -160,7 +155,7 @@ namespace Jellyfin.Networking.Tests
[InlineData("2001:db8:abcd:0012::0/128", "2001:0DB8:ABCD:0012:0000:0000:0000:0001")]
public void IPv6SubnetMaskDoesNotMatchInvalidIPAddress(string netMask, string ipAddress)
{
- Assert.False(NetworkExtensions.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
+ Assert.False(NetworkUtils.TryParseToSubnet(netMask, out var subnet) && subnet.Contains(IPAddress.Parse(ipAddress)));
}
[Theory]
@@ -207,7 +202,7 @@ namespace Jellyfin.Networking.Tests
NetworkManager.MockNetworkSettings = string.Empty;
// Check to see if DNS resolution is working. If not, skip test.
- if (!NetworkExtensions.TryParseHost(source, out var host))
+ if (!NetworkUtils.TryParseHost(source, out var host))
{
return;
}
diff --git a/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs b/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs
index f157f01e5..be5a401b1 100644
--- a/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs
+++ b/tests/Jellyfin.Providers.Tests/Manager/ItemImageProviderTests.cs
@@ -27,7 +27,7 @@ namespace Jellyfin.Providers.Tests.Manager
{
public partial class ItemImageProviderTests
{
- private const string TestDataImagePath = "Test Data/Images/blank{0}.jpg";
+ private static readonly CompositeFormat _testDataImagePath = CompositeFormat.Parse("Test Data/Images/blank{0}.jpg");
[GeneratedRegex("[0-9]+")]
private static partial Regex NumbersRegex();
@@ -275,7 +275,7 @@ namespace Jellyfin.Providers.Tests.Manager
{
HasImage = true,
Format = ImageFormat.Jpg,
- Path = responseHasPath ? string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 0) : null,
+ Path = responseHasPath ? string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 0) : null,
Protocol = protocol
};
@@ -352,11 +352,11 @@ namespace Jellyfin.Providers.Tests.Manager
{
if (forceRefresh)
{
- Assert.Matches(@"image url [0-9]", image.Path);
+ Assert.Matches("image url [0-9]", image.Path);
}
else
{
- Assert.DoesNotMatch(@"image url [0-9]", image.Path);
+ Assert.DoesNotMatch("image url [0-9]", image.Path);
}
}
}
@@ -563,21 +563,21 @@ namespace Jellyfin.Providers.Tests.Manager
mockFileSystem.Setup(fs => fs.GetFilePaths(It.IsAny<string>(), It.IsAny<bool>()))
.Returns(new[]
{
- string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 0),
- string.Format(CultureInfo.InvariantCulture, TestDataImagePath, 1)
+ string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 0),
+ string.Format(CultureInfo.InvariantCulture, _testDataImagePath, 1)
});
return new ItemImageProvider(new NullLogger<ItemImageProvider>(), providerManager, mockFileSystem.Object);
}
- private static BaseItem GetItemWithImages(ImageType type, int count, bool validPaths)
+ private static Video GetItemWithImages(ImageType type, int count, bool validPaths)
{
// Has to exist for querying DateModified time on file, results stored but not checked so not populating
BaseItem.FileSystem ??= Mock.Of<IFileSystem>();
var item = new Video();
- var path = validPaths ? TestDataImagePath : "invalid path {0}";
+ var path = validPaths ? _testDataImagePath.Format : "invalid path {0}";
for (int i = 0; i < count; i++)
{
item.SetImagePath(type, i, new FileSystemMetadata
@@ -604,7 +604,7 @@ namespace Jellyfin.Providers.Tests.Manager
/// </summary>
private static LocalImageInfo[] GetImages(ImageType type, int count, bool validPaths)
{
- var path = validPaths ? TestDataImagePath : "invalid path {0}";
+ var path = validPaths ? _testDataImagePath.Format : "invalid path {0}";
var images = new LocalImageInfo[count];
for (int i = 0; i < count; i++)
{
diff --git a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs
index 6ee4b8ef2..2b3867512 100644
--- a/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs
+++ b/tests/Jellyfin.Providers.Tests/MediaInfo/MediaInfoResolverTests.cs
@@ -29,7 +29,7 @@ public class MediaInfoResolverTests
public const string VideoDirectoryPath = "Test Data/Video";
public const string VideoDirectoryRegex = @"Test Data[/\\]Video";
public const string MetadataDirectoryPath = "library/00/00000000000000000000000000000000";
- public const string MetadataDirectoryRegex = @"library.*";
+ public const string MetadataDirectoryRegex = "library.*";
private readonly ILocalizationManager _localizationManager;
private readonly MediaInfoResolver _subtitleResolver;
@@ -49,7 +49,7 @@ public class MediaInfoResolverTests
var englishCultureDto = new CultureDto("English", "English", "en", new[] { "eng" });
var localizationManager = new Mock<ILocalizationManager>(MockBehavior.Loose);
- localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex(@"en.*", RegexOptions.IgnoreCase)))
+ localizationManager.Setup(lm => lm.FindLanguageInfo(It.IsRegex("en.*", RegexOptions.IgnoreCase)))
.Returns(englishCultureDto);
_localizationManager = localizationManager.Object;
@@ -79,7 +79,7 @@ public class MediaInfoResolverTests
{
// need a media source manager capable of returning something other than file protocol
var mediaSourceManager = new Mock<IMediaSourceManager>();
- mediaSourceManager.Setup(m => m.GetPathProtocol(It.IsRegex(@"http.*")))
+ mediaSourceManager.Setup(m => m.GetPathProtocol(It.IsRegex("http.*")))
.Returns(MediaProtocol.Http);
BaseItem.MediaSourceManager = mediaSourceManager.Object;
@@ -186,7 +186,7 @@ public class MediaInfoResolverTests
{
// need a media source manager capable of returning something other than file protocol
var mediaSourceManager = new Mock<IMediaSourceManager>();
- mediaSourceManager.Setup(m => m.GetPathProtocol(It.IsRegex(@"http.*")))
+ mediaSourceManager.Setup(m => m.GetPathProtocol(It.IsRegex("http.*")))
.Returns(MediaProtocol.Http);
BaseItem.MediaSourceManager = mediaSourceManager.Object;
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/AudioResolverTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/AudioResolverTests.cs
index d136c1bc6..5aa7c04f6 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Library/AudioResolverTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Library/AudioResolverTests.cs
@@ -1,6 +1,7 @@
using System.Linq;
using Emby.Naming.Common;
using Emby.Server.Implementations.Library.Resolvers.Audio;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO;
@@ -62,7 +63,7 @@ public class AudioResolverTests
null,
Mock.Of<ILibraryManager>())
{
- CollectionType = "books",
+ CollectionType = CollectionType.books,
FileInfo = new FileSystemMetadata
{
FullName = parent,
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/EpisodeResolverTest.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/EpisodeResolverTest.cs
index 6d0ed7bbb..cc2e47c33 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Library/EpisodeResolverTest.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Library/EpisodeResolverTest.cs
@@ -1,5 +1,6 @@
using Emby.Naming.Common;
using Emby.Server.Implementations.Library.Resolvers.TV;
+using Jellyfin.Data.Enums;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
@@ -28,7 +29,7 @@ namespace Jellyfin.Server.Implementations.Tests.Library
null)
{
Parent = parent,
- CollectionType = CollectionType.TvShows,
+ CollectionType = CollectionType.tvshows,
FileInfo = new FileSystemMetadata
{
FullName = "All My Children/Season 01/Extras/All My Children S01E01 - Behind The Scenes.mkv"
@@ -51,7 +52,7 @@ namespace Jellyfin.Server.Implementations.Tests.Library
null)
{
Parent = series,
- CollectionType = CollectionType.TvShows,
+ CollectionType = CollectionType.tvshows,
FileInfo = new FileSystemMetadata
{
FullName = "Extras/Extras S01E01.mkv"
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs
index c33a957e6..1c35eb3f5 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs
@@ -48,10 +48,10 @@ namespace Jellyfin.Server.Implementations.Tests.Library
[InlineData("C:/Users/jeff/myfile.mkv", "C:/Users/jeff", "/home/jeff", "/home/jeff/myfile.mkv")]
[InlineData("C:/Users/jeff/myfile.mkv", "C:/Users/jeff/", "/home/jeff", "/home/jeff/myfile.mkv")]
[InlineData("/home/jeff/music/jeff's band/consistently inconsistent.mp3", "/home/jeff/music/jeff's band", "/home/not jeff", "/home/not jeff/consistently inconsistent.mp3")]
- [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff", "/home/jeff", "/home/jeff/myfile.mkv")]
- [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff", "/home/jeff/", "/home/jeff/myfile.mkv")]
- [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff/", "/home/jeff/", "/home/jeff/myfile.mkv")]
- [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff/", "/", "/myfile.mkv")]
+ [InlineData(@"C:\Users\jeff\myfile.mkv", "C:\\Users/jeff", "/home/jeff", "/home/jeff/myfile.mkv")]
+ [InlineData(@"C:\Users\jeff\myfile.mkv", "C:\\Users/jeff", "/home/jeff/", "/home/jeff/myfile.mkv")]
+ [InlineData(@"C:\Users\jeff\myfile.mkv", "C:\\Users/jeff/", "/home/jeff/", "/home/jeff/myfile.mkv")]
+ [InlineData(@"C:\Users\jeff\myfile.mkv", "C:\\Users/jeff/", "/", "/myfile.mkv")]
[InlineData("/o", "/o", "/s", "/s")] // regression test for #5977
public void TryReplaceSubPath_ValidArgs_Correct(string path, string subPath, string newSubPath, string? expectedResult)
{
@@ -78,10 +78,10 @@ namespace Jellyfin.Server.Implementations.Tests.Library
[Theory]
[InlineData(null, '/', null)]
[InlineData(null, '\\', null)]
- [InlineData("/home/jeff/myfile.mkv", '\\', "\\home\\jeff\\myfile.mkv")]
- [InlineData("C:\\Users\\Jeff\\myfile.mkv", '/', "C:/Users/Jeff/myfile.mkv")]
- [InlineData("\\home/jeff\\myfile.mkv", '\\', "\\home\\jeff\\myfile.mkv")]
- [InlineData("\\home/jeff\\myfile.mkv", '/', "/home/jeff/myfile.mkv")]
+ [InlineData("/home/jeff/myfile.mkv", '\\', @"\home\jeff\myfile.mkv")]
+ [InlineData(@"C:\Users\Jeff\myfile.mkv", '/', "C:/Users/Jeff/myfile.mkv")]
+ [InlineData(@"\home/jeff\myfile.mkv", '\\', @"\home\jeff\myfile.mkv")]
+ [InlineData(@"\home/jeff\myfile.mkv", '/', "/home/jeff/myfile.mkv")]
[InlineData("", '/', "")]
public void NormalizePath_SpecifyingSeparator_Normalizes(string path, char separator, string expectedPath)
{
@@ -90,8 +90,8 @@ namespace Jellyfin.Server.Implementations.Tests.Library
[Theory]
[InlineData("/home/jeff/myfile.mkv")]
- [InlineData("C:\\Users\\Jeff\\myfile.mkv")]
- [InlineData("\\home/jeff\\myfile.mkv")]
+ [InlineData(@"C:\Users\Jeff\myfile.mkv")]
+ [InlineData(@"\home/jeff\myfile.mkv")]
public void NormalizePath_NoArgs_UsesDirectorySeparatorChar(string path)
{
var separator = Path.DirectorySeparatorChar;
@@ -101,8 +101,8 @@ namespace Jellyfin.Server.Implementations.Tests.Library
[Theory]
[InlineData("/home/jeff/myfile.mkv", '/')]
- [InlineData("C:\\Users\\Jeff\\myfile.mkv", '\\')]
- [InlineData("\\home/jeff\\myfile.mkv", '/')]
+ [InlineData(@"C:\Users\Jeff\myfile.mkv", '\\')]
+ [InlineData(@"\home/jeff\myfile.mkv", '/')]
public void NormalizePath_OutVar_Correct(string path, char expectedSeparator)
{
var result = path.NormalizePath(out var separator);
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Plugins/PluginManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Plugins/PluginManagerTests.cs
index d4b90dac0..934024826 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Plugins/PluginManagerTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Plugins/PluginManagerTests.cs
@@ -119,8 +119,8 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
[InlineData("C:\\some.dll")] // Windows root path.
[InlineData("test.txt")] // Not a DLL
[InlineData(".././.././../some.dll")] // Traversal with current and parent
- [InlineData("..\\.\\..\\.\\..\\some.dll")] // Windows traversal with current and parent
- [InlineData("\\\\network\\resource.dll")] // UNC Path
+ [InlineData(@"..\.\..\.\..\some.dll")] // Windows traversal with current and parent
+ [InlineData(@"\\network\resource.dll")] // UNC Path
[InlineData("https://jellyfin.org/some.dll")] // URL
[InlineData("~/some.dll")] // Tilde poses a shell expansion risk, but is a valid path character.
public void Constructor_DiscoversUnsafePluginAssembly_Status_Malfunctioned(string unsafePath)
@@ -191,13 +191,13 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
};
var metafilePath = Path.Combine(_pluginPath, "meta.json");
- File.WriteAllText(metafilePath, JsonSerializer.Serialize(partial, _options));
+ await File.WriteAllTextAsync(metafilePath, JsonSerializer.Serialize(partial, _options));
var pluginManager = new PluginManager(new NullLogger<PluginManager>(), null!, null!, _tempPath, new Version(1, 0));
await pluginManager.PopulateManifest(packageInfo, new Version(1, 0), _pluginPath, PluginStatus.Active);
- var resultBytes = File.ReadAllBytes(metafilePath);
+ var resultBytes = await File.ReadAllBytesAsync(metafilePath);
var result = JsonSerializer.Deserialize<PluginManifest>(resultBytes, _options);
Assert.NotNull(result);
@@ -231,7 +231,7 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
await pluginManager.PopulateManifest(packageInfo, new Version(1, 0), _pluginPath, PluginStatus.Active);
var metafilePath = Path.Combine(_pluginPath, "meta.json");
- var resultBytes = File.ReadAllBytes(metafilePath);
+ var resultBytes = await File.ReadAllBytesAsync(metafilePath);
var result = JsonSerializer.Deserialize<PluginManifest>(resultBytes, _options);
Assert.NotNull(result);
@@ -251,13 +251,13 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
};
var metafilePath = Path.Combine(_pluginPath, "meta.json");
- File.WriteAllText(metafilePath, JsonSerializer.Serialize(partial, _options));
+ await File.WriteAllTextAsync(metafilePath, JsonSerializer.Serialize(partial, _options));
var pluginManager = new PluginManager(new NullLogger<PluginManager>(), null!, null!, _tempPath, new Version(1, 0));
await pluginManager.PopulateManifest(packageInfo, new Version(1, 0), _pluginPath, PluginStatus.Active);
- var resultBytes = File.ReadAllBytes(metafilePath);
+ var resultBytes = await File.ReadAllBytesAsync(metafilePath);
var result = JsonSerializer.Deserialize<PluginManifest>(resultBytes, _options);
Assert.NotNull(result);
@@ -277,13 +277,13 @@ namespace Jellyfin.Server.Implementations.Tests.Plugins
};
var metafilePath = Path.Combine(_pluginPath, "meta.json");
- File.WriteAllText(metafilePath, JsonSerializer.Serialize(partial, _options));
+ await File.WriteAllTextAsync(metafilePath, JsonSerializer.Serialize(partial, _options));
var pluginManager = new PluginManager(new NullLogger<PluginManager>(), null!, null!, _tempPath, new Version(1, 0));
await pluginManager.PopulateManifest(packageInfo, new Version(1, 0), _pluginPath, PluginStatus.Active);
- var resultBytes = File.ReadAllBytes(metafilePath);
+ var resultBytes = await File.ReadAllBytesAsync(metafilePath);
var result = JsonSerializer.Deserialize<PluginManifest>(resultBytes, _options);
Assert.NotNull(result);
diff --git a/tests/Jellyfin.Server.Implementations.Tests/SessionManager/SessionManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/SessionManager/SessionManagerTests.cs
new file mode 100644
index 000000000..ebd3a3891
--- /dev/null
+++ b/tests/Jellyfin.Server.Implementations.Tests/SessionManager/SessionManagerTests.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Threading.Tasks;
+using Jellyfin.Data.Entities;
+using MediaBrowser.Controller;
+using MediaBrowser.Controller.Configuration;
+using MediaBrowser.Controller.Devices;
+using MediaBrowser.Controller.Drawing;
+using MediaBrowser.Controller.Dto;
+using MediaBrowser.Controller.Events;
+using MediaBrowser.Controller.Library;
+using MediaBrowser.Controller.Session;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging.Abstractions;
+using Moq;
+using Xunit;
+
+namespace Jellyfin.Server.Implementations.Tests.SessionManager;
+
+public class SessionManagerTests
+{
+ [Theory]
+ [InlineData("", typeof(ArgumentException))]
+ [InlineData(null, typeof(ArgumentNullException))]
+ public async Task GetAuthorizationToken_Should_ThrowException(string deviceId, Type exceptionType)
+ {
+ await using var sessionManager = new Emby.Server.Implementations.Session.SessionManager(
+ NullLogger<Emby.Server.Implementations.Session.SessionManager>.Instance,
+ Mock.Of<IEventManager>(),
+ Mock.Of<IUserDataManager>(),
+ Mock.Of<IServerConfigurationManager>(),
+ Mock.Of<ILibraryManager>(),
+ Mock.Of<IUserManager>(),
+ Mock.Of<IMusicManager>(),
+ Mock.Of<IDtoService>(),
+ Mock.Of<IImageProcessor>(),
+ Mock.Of<IServerApplicationHost>(),
+ Mock.Of<IDeviceManager>(),
+ Mock.Of<IMediaSourceManager>(),
+ Mock.Of<IHostApplicationLifetime>());
+
+ await Assert.ThrowsAsync(exceptionType, () => sessionManager.GetAuthorizationToken(
+ new User("test", "default", "default"),
+ deviceId,
+ "app_name",
+ "0.0.0",
+ "device_name"));
+ }
+
+ [Theory]
+ [MemberData(nameof(AuthenticateNewSessionInternal_Exception_TestData))]
+ public async Task AuthenticateNewSessionInternal_Should_ThrowException(AuthenticationRequest authenticationRequest, Type exceptionType)
+ {
+ await using var sessionManager = new Emby.Server.Implementations.Session.SessionManager(
+ NullLogger<Emby.Server.Implementations.Session.SessionManager>.Instance,
+ Mock.Of<IEventManager>(),
+ Mock.Of<IUserDataManager>(),
+ Mock.Of<IServerConfigurationManager>(),
+ Mock.Of<ILibraryManager>(),
+ Mock.Of<IUserManager>(),
+ Mock.Of<IMusicManager>(),
+ Mock.Of<IDtoService>(),
+ Mock.Of<IImageProcessor>(),
+ Mock.Of<IServerApplicationHost>(),
+ Mock.Of<IDeviceManager>(),
+ Mock.Of<IMediaSourceManager>(),
+ Mock.Of<IHostApplicationLifetime>());
+
+ await Assert.ThrowsAsync(exceptionType, () => sessionManager.AuthenticateNewSessionInternal(authenticationRequest, false));
+ }
+
+ public static TheoryData<AuthenticationRequest, Type> AuthenticateNewSessionInternal_Exception_TestData()
+ {
+ var data = new TheoryData<AuthenticationRequest, Type>
+ {
+ {
+ new AuthenticationRequest { App = string.Empty, DeviceId = "device_id", DeviceName = "device_name", AppVersion = "app_version" },
+ typeof(ArgumentException)
+ },
+ {
+ new AuthenticationRequest { App = null, DeviceId = "device_id", DeviceName = "device_name", AppVersion = "app_version" },
+ typeof(ArgumentNullException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = string.Empty, DeviceName = "device_name", AppVersion = "app_version" },
+ typeof(ArgumentException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = null, DeviceName = "device_name", AppVersion = "app_version" },
+ typeof(ArgumentNullException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = "device_id", DeviceName = string.Empty, AppVersion = "app_version" },
+ typeof(ArgumentException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = "device_id", DeviceName = null, AppVersion = "app_version" },
+ typeof(ArgumentNullException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = "device_id", DeviceName = "device_name", AppVersion = string.Empty },
+ typeof(ArgumentException)
+ },
+ {
+ new AuthenticationRequest { App = "app_name", DeviceId = "device_id", DeviceName = "device_name", AppVersion = null },
+ typeof(ArgumentNullException)
+ }
+ };
+
+ return data;
+ }
+}
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Sorting/AiredEpisodeOrderComparerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Sorting/AiredEpisodeOrderComparerTests.cs
index 1dd49b2cf..ad85bdb6e 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Sorting/AiredEpisodeOrderComparerTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Sorting/AiredEpisodeOrderComparerTests.cs
@@ -9,22 +9,21 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
{
public class AiredEpisodeOrderComparerTests
{
+ private readonly AiredEpisodeOrderComparer _cmp = new AiredEpisodeOrderComparer();
+
[Theory]
[ClassData(typeof(EpisodeBadData))]
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem? x, BaseItem? y)
{
- var cmp = new AiredEpisodeOrderComparer();
- Assert.Throws<ArgumentNullException>(() => cmp.Compare(x, y));
+ Assert.Throws<ArgumentNullException>(() => _cmp.Compare(x, y));
}
[Theory]
[ClassData(typeof(EpisodeTestData))]
public void AiredEpisodeOrderCompareTest(BaseItem x, BaseItem y, int expected)
{
- var cmp = new AiredEpisodeOrderComparer();
-
- Assert.Equal(expected, cmp.Compare(x, y));
- Assert.Equal(-expected, cmp.Compare(y, x));
+ Assert.Equal(expected, _cmp.Compare(x, y));
+ Assert.Equal(-expected, _cmp.Compare(y, x));
}
private sealed class EpisodeBadData : TheoryData<BaseItem?, BaseItem?>
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Sorting/IndexNumberComparerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Sorting/IndexNumberComparerTests.cs
index 18588bd67..52f71ef4a 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Sorting/IndexNumberComparerTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Sorting/IndexNumberComparerTests.cs
@@ -9,7 +9,7 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting;
public class IndexNumberComparerTests
{
- private readonly IBaseItemComparer _cmp = new IndexNumberComparer();
+ private readonly IndexNumberComparer _cmp = new IndexNumberComparer();
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
=> new()
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Sorting/ParentIndexNumberComparerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Sorting/ParentIndexNumberComparerTests.cs
index 261092e01..bedd187eb 100644
--- a/tests/Jellyfin.Server.Implementations.Tests/Sorting/ParentIndexNumberComparerTests.cs
+++ b/tests/Jellyfin.Server.Implementations.Tests/Sorting/ParentIndexNumberComparerTests.cs
@@ -9,7 +9,7 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting;
public class ParentIndexNumberComparerTests
{
- private readonly IBaseItemComparer _cmp = new ParentIndexNumberComparer();
+ private readonly ParentIndexNumberComparer _cmp = new ParentIndexNumberComparer();
public static TheoryData<BaseItem?, BaseItem?> Compare_GivenNull_ThrowsArgumentNullException_TestData()
=> new()
diff --git a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs b/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs
deleted file mode 100644
index e5d5e785c..000000000
--- a/tests/Jellyfin.Server.Integration.Tests/Controllers/DlnaControllerTests.cs
+++ /dev/null
@@ -1,154 +0,0 @@
-using System;
-using System.Linq;
-using System.Net;
-using System.Net.Http.Json;
-using System.Net.Mime;
-using System.Text;
-using System.Text.Json;
-using System.Threading.Tasks;
-using Jellyfin.Extensions.Json;
-using MediaBrowser.Model.Dlna;
-using Xunit;
-using Xunit.Priority;
-
-namespace Jellyfin.Server.Integration.Tests.Controllers
-{
- [TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]
- public sealed class DlnaControllerTests : IClassFixture<JellyfinApplicationFactory>
- {
- private const string NonExistentProfile = "1322f35b8f2c434dad3cc07c9b97dbd1";
- private readonly JellyfinApplicationFactory _factory;
- private readonly JsonSerializerOptions _jsonOptions = JsonDefaults.Options;
- private static string? _accessToken;
- private static string? _newDeviceProfileId;
-
- public DlnaControllerTests(JellyfinApplicationFactory factory)
- {
- _factory = factory;
- }
-
- [Fact]
- [Priority(0)]
- public async Task GetProfile_DoesNotExist_NotFound()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- using var response = await client.GetAsync("/Dlna/Profiles/" + NonExistentProfile);
- Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
- }
-
- [Fact]
- [Priority(0)]
- public async Task DeleteProfile_DoesNotExist_NotFound()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- using var response = await client.DeleteAsync("/Dlna/Profiles/" + NonExistentProfile);
- Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
- }
-
- [Fact]
- [Priority(0)]
- public async Task UpdateProfile_DoesNotExist_NotFound()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- var deviceProfile = new DeviceProfile()
- {
- Name = "ThisProfileDoesNotExist"
- };
-
- using var response = await client.PostAsJsonAsync("/Dlna/Profiles/" + NonExistentProfile, deviceProfile, _jsonOptions);
- Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
- }
-
- [Fact]
- [Priority(1)]
- public async Task CreateProfile_Valid_NoContent()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- var deviceProfile = new DeviceProfile()
- {
- Name = "ThisProfileIsNew"
- };
-
- using var response = await client.PostAsJsonAsync("/Dlna/Profiles", deviceProfile, _jsonOptions);
- Assert.Equal(HttpStatusCode.NoContent, response.StatusCode);
- }
-
- [Fact]
- [Priority(2)]
- public async Task GetProfileInfos_Valid_ContainsThisProfileIsNew()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- using var response = await client.GetAsync("/Dlna/ProfileInfos");
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
- Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
-
- var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions);
-
- var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal));
- Assert.NotNull(newProfile);
- _newDeviceProfileId = newProfile!.Id;
- }
-
- [Fact]
- [Priority(3)]
- public async Task UpdateProfile_Valid_NoContent()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- var updatedProfile = new DeviceProfile()
- {
- Name = "ThisProfileIsUpdated",
- Id = _newDeviceProfileId
- };
-
- using var postResponse = await client.PostAsJsonAsync("/Dlna/Profiles/" + _newDeviceProfileId, updatedProfile, _jsonOptions);
- Assert.Equal(HttpStatusCode.NoContent, postResponse.StatusCode);
-
- // Verify that the profile got updated
- using var response = await client.GetAsync("/Dlna/ProfileInfos");
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
- Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
-
- var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions);
-
- Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsNew", StringComparison.Ordinal)));
- var newProfile = profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal));
- Assert.NotNull(newProfile);
- _newDeviceProfileId = newProfile!.Id;
- }
-
- [Fact]
- [Priority(5)]
- public async Task DeleteProfile_Valid_NoContent()
- {
- var client = _factory.CreateClient();
- client.DefaultRequestHeaders.AddAuthHeader(_accessToken ??= await AuthHelper.CompleteStartupAsync(client));
-
- using var deleteResponse = await client.DeleteAsync("/Dlna/Profiles/" + _newDeviceProfileId);
- Assert.Equal(HttpStatusCode.NoContent, deleteResponse.StatusCode);
-
- // Verify that the profile got deleted
- using var response = await client.GetAsync("/Dlna/ProfileInfos");
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- Assert.Equal(MediaTypeNames.Application.Json, response.Content.Headers.ContentType?.MediaType);
- Assert.Equal(Encoding.UTF8.BodyName, response.Content.Headers.ContentType?.CharSet);
-
- var profiles = await response.Content.ReadFromJsonAsync<DeviceProfileInfo[]>(_jsonOptions);
-
- Assert.Null(profiles?.FirstOrDefault(x => string.Equals(x.Name, "ThisProfileIsUpdated", StringComparison.Ordinal)));
- }
- }
-}
diff --git a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
index 1c87d11f1..a078eff77 100644
--- a/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
+++ b/tests/Jellyfin.Server.Integration.Tests/JellyfinApplicationFactory.cs
@@ -8,9 +8,9 @@ using Jellyfin.Server.Helpers;
using MediaBrowser.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
-using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Serilog;
@@ -39,9 +39,9 @@ namespace Jellyfin.Server.Integration.Tests
}
/// <inheritdoc/>
- protected override IWebHostBuilder CreateWebHostBuilder()
+ protected override IHostBuilder CreateHostBuilder()
{
- return new WebHostBuilder();
+ return new HostBuilder();
}
/// <inheritdoc/>
@@ -95,18 +95,17 @@ namespace Jellyfin.Server.Integration.Tests
}
/// <inheritdoc/>
- protected override TestServer CreateServer(IWebHostBuilder builder)
+ protected override IHost CreateHost(IHostBuilder builder)
{
- // Create the test server using the base implementation
- var testServer = base.CreateServer(builder);
-
- // Finish initializing the app host
- var appHost = (TestAppHost)testServer.Services.GetRequiredService<IApplicationHost>();
- appHost.ServiceProvider = testServer.Services;
+ var host = builder.Build();
+ var appHost = (TestAppHost)host.Services.GetRequiredService<IApplicationHost>();
+ appHost.ServiceProvider = host.Services;
appHost.InitializeServices().GetAwaiter().GetResult();
+ host.Start();
+
appHost.RunStartupTasksAsync().GetAwaiter().GetResult();
- return testServer;
+ return host;
}
/// <inheritdoc/>
diff --git a/tests/Jellyfin.Server.Tests/ParseNetworkTests.cs b/tests/Jellyfin.Server.Tests/ParseNetworkTests.cs
index 288102037..123266d29 100644
--- a/tests/Jellyfin.Server.Tests/ParseNetworkTests.cs
+++ b/tests/Jellyfin.Server.Tests/ParseNetworkTests.cs
@@ -1,16 +1,17 @@
using System;
using System.Linq;
using System.Net;
-using Jellyfin.Networking.Configuration;
using Jellyfin.Networking.Manager;
using Jellyfin.Server.Extensions;
using MediaBrowser.Common.Configuration;
+using MediaBrowser.Common.Net;
using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using Moq;
using Xunit;
+using IConfigurationManager = MediaBrowser.Common.Configuration.IConfigurationManager;
+using IPNetwork = Microsoft.AspNetCore.HttpOverrides.IPNetwork;
namespace Jellyfin.Server.Tests
{
diff --git a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
index f56f58c6f..0a153b9cc 100644
--- a/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
+++ b/tests/Jellyfin.XbmcMetadata.Tests/Parsers/MovieNfoParserTests.cs
@@ -60,7 +60,7 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
{
Exists = true,
FullName = OperatingSystem.IsWindows() ?
- "C:\\media\\movies\\Justice League (2017).jpg"
+ @"C:\media\movies\Justice League (2017).jpg"
: "/media/movies/Justice League (2017).jpg"
};
directoryService.Setup(x => x.GetFile(_localImageFileMetadata.FullName))