Merge pull request #4317 from jellyfin/tests7
Fix AudioBookListResolver test coverage
This commit is contained in:
commit
86090ab1f6
|
@ -1,3 +1,4 @@
|
||||||
|
#nullable enable
|
||||||
#pragma warning disable CS1591
|
#pragma warning disable CS1591
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -16,21 +17,11 @@ namespace Emby.Naming.AudioBook
|
||||||
_options = options;
|
_options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AudioBookFileInfo ParseFile(string path)
|
public AudioBookFileInfo? Resolve(string path, bool isDirectory = false)
|
||||||
{
|
{
|
||||||
return Resolve(path, false);
|
if (path.Length == 0)
|
||||||
}
|
|
||||||
|
|
||||||
public AudioBookFileInfo ParseDirectory(string path)
|
|
||||||
{
|
{
|
||||||
return Resolve(path, true);
|
throw new ArgumentException("String can't be empty.", nameof(path));
|
||||||
}
|
|
||||||
|
|
||||||
public AudioBookFileInfo Resolve(string path, bool isDirectory = false)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(path))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(path));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Emby.Naming.AudioBook;
|
using Emby.Naming.AudioBook;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -42,16 +43,22 @@ namespace Jellyfin.Naming.Tests.AudioBook
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[MemberData(nameof(GetResolveFileTestData))]
|
[MemberData(nameof(GetResolveFileTestData))]
|
||||||
public void ResolveFile_ValidFileName_Success(AudioBookFileInfo expectedResult)
|
public void Resolve_ValidFileName_Success(AudioBookFileInfo expectedResult)
|
||||||
{
|
{
|
||||||
var result = new AudioBookResolver(_namingOptions).Resolve(expectedResult.Path);
|
var result = new AudioBookResolver(_namingOptions).Resolve(expectedResult.Path);
|
||||||
|
|
||||||
Assert.NotNull(result);
|
Assert.NotNull(result);
|
||||||
Assert.Equal(result.Path, expectedResult.Path);
|
Assert.Equal(result!.Path, expectedResult.Path);
|
||||||
Assert.Equal(result.Container, expectedResult.Container);
|
Assert.Equal(result!.Container, expectedResult.Container);
|
||||||
Assert.Equal(result.ChapterNumber, expectedResult.ChapterNumber);
|
Assert.Equal(result!.ChapterNumber, expectedResult.ChapterNumber);
|
||||||
Assert.Equal(result.PartNumber, expectedResult.PartNumber);
|
Assert.Equal(result!.PartNumber, expectedResult.PartNumber);
|
||||||
Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
|
Assert.Equal(result!.IsDirectory, expectedResult.IsDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Resolve_EmptyFileName_ArgumentException()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentException>(() => new AudioBookResolver(_namingOptions).Resolve(string.Empty));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user