aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorStepan <ste.martinek+git@gmail.com>2020-11-02 20:03:12 +0100
committerStepan <ste.martinek+git@gmail.com>2020-11-02 20:03:12 +0100
commit1e7177568887d0f808660454e5eb7ca7ebcd6998 (patch)
tree0359804e2c4d691a7cf476c7364cefded0ab2947 /tests
parent50a2ef9d8aaf92e8b69ced5ea2fcc8fa185fe675 (diff)
Add Name and Year parsing for audiobooks
Diffstat (limited to 'tests')
-rw-r--r--tests/Jellyfin.Naming.Tests/AudioBook/AudioBookListResolverTests.cs78
-rw-r--r--tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs1
2 files changed, 61 insertions, 18 deletions
diff --git a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookListResolverTests.cs b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookListResolverTests.cs
index c4b061b4e9..91492d46c9 100644
--- a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookListResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookListResolverTests.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Linq;
using Emby.Naming.AudioBook;
using Emby.Naming.Common;
@@ -72,33 +73,69 @@ namespace Jellyfin.Naming.Tests.AudioBook
}
[Fact]
- public void TestYearExtraction()
+ public void TestNameYearExtraction()
{
- var files = new[]
+ var data = new[]
{
- "Harry Potter and the Deathly Hallows (2007)/Chapter 1.ogg",
- "Harry Potter and the Deathly Hallows (2007)/Chapter 2.mp3",
-
- "Batman (2020).ogg",
-
- "Batman(2021).mp3",
-
- "Batman.mp3"
+ new NameYearPath
+ {
+ Name = "Harry Potter and the Deathly Hallows",
+ Path = "Harry Potter and the Deathly Hallows (2007)/Chapter 1.ogg",
+ Year = 2007
+ },
+ new NameYearPath
+ {
+ Name = "Batman",
+ Path = "Batman (2020).ogg",
+ Year = 2020
+ },
+ new NameYearPath
+ {
+ Name = "Batman",
+ Path = "Batman( 2021 ).mp3",
+ Year = 2021
+ },
+ new NameYearPath
+ {
+ Name = "Batman(*2021*)",
+ Path = "Batman(*2021*).mp3",
+ Year = null
+ },
+ new NameYearPath
+ {
+ Name = "Batman",
+ Path = "Batman.mp3",
+ Year = null
+ },
+ new NameYearPath
+ {
+ Name = "+ Batman .",
+ Path = " + Batman . .mp3",
+ Year = null
+ },
+ new NameYearPath
+ {
+ Name = " ",
+ Path = " .mp3",
+ Year = null
+ }
};
var resolver = GetResolver();
- var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
+ var result = resolver.Resolve(data.Select(i => new FileSystemMetadata
{
IsDirectory = false,
- FullName = i
+ FullName = i.Path
})).ToList();
- Assert.Equal(3, result[0].Files.Count);
- Assert.Equal(2007, result[0].Year);
- Assert.Equal(2020, result[1].Year);
- Assert.Equal(2021, result[2].Year);
- Assert.Null(result[2].Year);
+ Assert.Equal(data.Length, result.Count);
+
+ for (int i = 0; i < data.Length; i++)
+ {
+ Assert.Equal(data[i].Name, result[i].Name);
+ Assert.Equal(data[i].Year, result[i].Year);
+ }
}
[Fact]
@@ -180,5 +217,12 @@ namespace Jellyfin.Naming.Tests.AudioBook
{
return new AudioBookListResolver(_namingOptions);
}
+
+ internal struct NameYearPath
+ {
+ public string Name;
+ public string Path;
+ public int? Year;
+ }
}
}
diff --git a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
index 5e9d12970a..b3257ace3b 100644
--- a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
@@ -35,7 +35,6 @@ namespace Jellyfin.Naming.Tests.AudioBook
};
}
-
[Theory]
[MemberData(nameof(GetResolveFileTestData))]
public void Resolve_ValidFileName_Success(AudioBookFileInfo expectedResult)