Remove some BaseItem references to make ItemResolveArgs more usable for testing.

This commit is contained in:
Joe Rogers 2023-03-06 22:18:26 -05:00
parent 0de37e2ac2
commit 160baa02fd
No known key found for this signature in database
GPG Key ID: 0074AD57B8FDBBB4
6 changed files with 16 additions and 16 deletions

View File

@ -537,7 +537,7 @@ namespace Emby.Server.Implementations.Library
collectionType = GetContentTypeOverride(fullPath, true); collectionType = GetContentTypeOverride(fullPath, true);
} }
var args = new ItemResolveArgs(_configurationManager.ApplicationPaths, directoryService) var args = new ItemResolveArgs(_configurationManager.ApplicationPaths, directoryService, this)
{ {
Parent = parent, Parent = parent,
FileInfo = fileInfo, FileInfo = fileInfo,

View File

@ -120,7 +120,7 @@ namespace MediaBrowser.Controller.Entities
var path = ContainingFolderPath; var path = ContainingFolderPath;
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService) var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService, LibraryManager)
{ {
FileInfo = FileSystem.GetDirectoryInfo(path) FileInfo = FileSystem.GetDirectoryInfo(path)
}; };

View File

@ -288,7 +288,7 @@ namespace MediaBrowser.Controller.Entities
{ {
var path = ContainingFolderPath; var path = ContainingFolderPath;
var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService) var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService, LibraryManager)
{ {
FileInfo = FileSystem.GetDirectoryInfo(path), FileInfo = FileSystem.GetDirectoryInfo(path),
Parent = GetParent() as Folder, Parent = GetParent() as Folder,

View File

@ -23,6 +23,7 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
private readonly IServerApplicationPaths _appPaths; private readonly IServerApplicationPaths _appPaths;
private readonly ILibraryManager _libraryManager;
private LibraryOptions _libraryOptions; private LibraryOptions _libraryOptions;
/// <summary> /// <summary>
@ -30,10 +31,12 @@ namespace MediaBrowser.Controller.Library
/// </summary> /// </summary>
/// <param name="appPaths">The app paths.</param> /// <param name="appPaths">The app paths.</param>
/// <param name="directoryService">The directory service.</param> /// <param name="directoryService">The directory service.</param>
public ItemResolveArgs(IServerApplicationPaths appPaths, IDirectoryService directoryService) /// <param name="libraryManager">The library manager.</param>
public ItemResolveArgs(IServerApplicationPaths appPaths, IDirectoryService directoryService, ILibraryManager libraryManager)
{ {
_appPaths = appPaths; _appPaths = appPaths;
DirectoryService = directoryService; DirectoryService = directoryService;
_libraryManager = libraryManager;
} }
// TODO remove dependencies as properties, they should be injected where it makes sense // TODO remove dependencies as properties, they should be injected where it makes sense
@ -47,7 +50,7 @@ namespace MediaBrowser.Controller.Library
public LibraryOptions LibraryOptions public LibraryOptions LibraryOptions
{ {
get => _libraryOptions ??= Parent is null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent); get => _libraryOptions ??= Parent is null ? new LibraryOptions() : _libraryManager.GetLibraryOptions(Parent);
set => _libraryOptions = value; set => _libraryOptions = value;
} }
@ -231,21 +234,15 @@ namespace MediaBrowser.Controller.Library
/// <summary> /// <summary>
/// Gets the configured content type for the path. /// Gets the configured content type for the path.
/// </summary> /// </summary>
/// <remarks>
/// This is subject to future refactoring as it relies on a static property in BaseItem.
/// </remarks>
/// <returns>The configured content type.</returns> /// <returns>The configured content type.</returns>
public string GetConfiguredContentType() public string GetConfiguredContentType()
{ {
return BaseItem.LibraryManager.GetConfiguredContentType(Path); return _libraryManager.GetConfiguredContentType(Path);
} }
/// <summary> /// <summary>
/// Gets the file system children that do not hit the ignore file check. /// Gets the file system children that do not hit the ignore file check.
/// </summary> /// </summary>
/// <remarks>
/// This is subject to future refactoring as it relies on a static property in BaseItem.
/// </remarks>
/// <returns>The file system children that are not ignored.</returns> /// <returns>The file system children that are not ignored.</returns>
public IEnumerable<FileSystemMetadata> GetActualFileSystemChildren() public IEnumerable<FileSystemMetadata> GetActualFileSystemChildren()
{ {
@ -253,7 +250,7 @@ namespace MediaBrowser.Controller.Library
for (var i = 0; i < numberOfChildren; i++) for (var i = 0; i < numberOfChildren; i++)
{ {
var child = FileSystemChildren[i]; var child = FileSystemChildren[i];
if (BaseItem.LibraryManager.IgnoreFile(child, Parent)) if (_libraryManager.IgnoreFile(child, Parent))
{ {
continue; continue;
} }

View File

@ -25,7 +25,8 @@ namespace Jellyfin.Server.Implementations.Tests.Library
var episodeResolver = new EpisodeResolver(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions); var episodeResolver = new EpisodeResolver(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions);
var itemResolveArgs = new ItemResolveArgs( var itemResolveArgs = new ItemResolveArgs(
Mock.Of<IServerApplicationPaths>(), Mock.Of<IServerApplicationPaths>(),
Mock.Of<IDirectoryService>()) Mock.Of<IDirectoryService>(),
null)
{ {
Parent = parent, Parent = parent,
CollectionType = CollectionType.TvShows, CollectionType = CollectionType.TvShows,
@ -48,7 +49,8 @@ namespace Jellyfin.Server.Implementations.Tests.Library
var episodeResolver = new EpisodeResolverMock(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions); var episodeResolver = new EpisodeResolverMock(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions);
var itemResolveArgs = new ItemResolveArgs( var itemResolveArgs = new ItemResolveArgs(
Mock.Of<IServerApplicationPaths>(), Mock.Of<IServerApplicationPaths>(),
Mock.Of<IDirectoryService>()) Mock.Of<IDirectoryService>(),
null)
{ {
Parent = series, Parent = series,
CollectionType = CollectionType.TvShows, CollectionType = CollectionType.TvShows,

View File

@ -21,7 +21,8 @@ public class MovieResolverTests
var movieResolver = new MovieResolver(Mock.Of<IImageProcessor>(), Mock.Of<ILogger<MovieResolver>>(), _namingOptions); var movieResolver = new MovieResolver(Mock.Of<IImageProcessor>(), Mock.Of<ILogger<MovieResolver>>(), _namingOptions);
var itemResolveArgs = new ItemResolveArgs( var itemResolveArgs = new ItemResolveArgs(
Mock.Of<IServerApplicationPaths>(), Mock.Of<IServerApplicationPaths>(),
Mock.Of<IDirectoryService>()) Mock.Of<IDirectoryService>(),
null)
{ {
Parent = null, Parent = null,
FileInfo = new FileSystemMetadata FileInfo = new FileSystemMetadata