Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to prefer movie.nfo when reading/writing nfo files #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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