Skip to content

Commit

Permalink
Added option to use prefer movie.nfo
Browse files Browse the repository at this point in the history
  • Loading branch information
randellhodges committed Sep 28, 2024
1 parent 7bd869b commit 770a1a4
Show file tree
Hide file tree
Showing 58 changed files with 1,010 additions and 253 deletions.
160 changes: 160 additions & 0 deletions NfoMetadata.Tests/HelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
using System.Collections;
using System.Linq;

using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;

using NUnit.Framework;

namespace NfoMetadata.Tests
{
public class HelperTests
{
private class TestItem : Video
{
}

[OneTimeSetUp]
public void OneTimeSetup()
{
BaseItem.MediaSourceManager = new TestMediaSourceManager();
BaseItem.FileSystem = new TestFileSystem();
}

[SetUp]
public void Setup()
{
}

public static IEnumerable SavePathTestCases_MKV
{
get
{
#region MKV (not mix folder)

yield return
new TestCaseData(
MediaContainer.Mkv.ToString(),
@"C:\Video\Movies\9 (2009)\9 (2009) - BluRay 1080p DTS x264-Group.mkv",
false,
false
)
.Returns(new[]
{
(@"C:\Video\Movies\9 (2009)", "9 (2009) - BluRay 1080p DTS x264-Group.nfo"),
(@"C:\Video\Movies\9 (2009)", "movie.nfo")
});

yield return
new TestCaseData(
MediaContainer.Mkv.ToString(),
@"C:\Video\Movies\9 (2009)\9 (2009) - BluRay 1080p DTS x264-Group.mkv",
false,
true
)
.Returns(new[]
{
(@"C:\Video\Movies\9 (2009)", "movie.nfo"),
(@"C:\Video\Movies\9 (2009)", "9 (2009) - BluRay 1080p DTS x264-Group.nfo")
});

#endregion

#region MKV (Mixed Folder)

yield return
new TestCaseData(
MediaContainer.Mkv.ToString(),
@"C:\Video\Movies\9 (2009)\9 (2009) - BluRay 1080p DTS x264-Group.mkv",
true,
false
)
.Returns(new[]
{
(@"C:\Video\Movies\9 (2009)", "9 (2009) - BluRay 1080p DTS x264-Group.nfo")
});

yield return
new TestCaseData(
MediaContainer.Mkv.ToString(),
@"C:\Video\Movies\9 (2009)\9 (2009) - BluRay 1080p DTS x264-Group.mkv",
true,
true
)
.Returns(new[]
{
(@"C:\Video\Movies\9 (2009)", "9 (2009) - BluRay 1080p DTS x264-Group.nfo")
});

#endregion
}
}

public static IEnumerable SavePathTestCases_DVD
{
get
{
#region Dvd

yield return
new TestCaseData(
MediaContainer.Dvd.ToString(),
@"C:\Video\Movies\Léon (1994)",
false,
false
)
.Returns(new[]
{
(@"C:\Video\Movies\Léon (1994)\VIDEO_TS", "VIDEO_TS.nfo"),
(@"C:\Video\Movies\Léon (1994)", "Léon (1994).nfo")
});

#endregion
}
}

public static IEnumerable SavePathTestCases_BluRay
{
get
{
#region BluRay

yield return
new TestCaseData(
MediaContainer.Bluray.ToString(),
@"E:\Movies\Movies\Alien (1979)",
false,
false
)
.Returns(new[]
{
(@"E:\Movies\Movies\Alien (1979)\BDMV", "index.nfo"),
(@"E:\Movies\Movies\Alien (1979)", "Alien (1979).nfo")
});

#endregion
}
}

[TestCaseSource(nameof(SavePathTestCases_MKV))]
[TestCaseSource(nameof(SavePathTestCases_DVD))]
[TestCaseSource(nameof(SavePathTestCases_BluRay))]
public (string, string)[] Validate_File_SavePaths(string container, string path, bool isInMixedFolder, bool preferMovieNfo)
{
var itemInfo = new ItemInfo(new TestItem
{
Container = container,
Path = path,
IsInMixedFolder = isInMixedFolder,
});

var actual = Helpers
.GetMovieSavePaths(itemInfo, new Configuration.XbmcMetadataOptions { PreferMovieNfo = preferMovieNfo })
.ToArray();

return actual;
}
}
}
26 changes: 26 additions & 0 deletions NfoMetadata.Tests/NfoMetadata.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\NfoMetadata\NfoMetadata.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 770a1a4

Please sign in to comment.