Merge pull request #3105 from aled/2149-fix-warnings-in-jellyfin.naming.tests

Fix compile warnings in Jellyfin.Naming.Tests
pull/3133/head
dkanada 5 years ago committed by GitHub
commit 7f39d898b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<!-- ProjectGuid is only included as a requirement for SonarQube analysis -->
<PropertyGroup>
@ -21,5 +21,15 @@
<ItemGroup>
<ProjectReference Include="..\..\Emby.Naming\Emby.Naming.csproj" />
</ItemGroup>
<!-- Code Analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" PrivateAssets="All" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CodeAnalysisRuleSet>../jellyfin-tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>

@ -23,9 +23,9 @@ namespace Jellyfin.Naming.Tests.Subtitles
var result = parser.ParseFile(input);
Assert.Equal(language, result.Language, true);
Assert.Equal(isDefault, result.IsDefault);
Assert.Equal(isForced, result.IsForced);
Assert.Equal(language, result?.Language, true);
Assert.Equal(isDefault, result?.IsDefault);
Assert.Equal(isForced, result?.IsForced);
}
[Theory]

@ -21,7 +21,7 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(options)
.Resolve(path, false, null, null, true);
Assert.Equal(episodeNumber, result.EpisodeNumber);
Assert.Equal(episodeNumber, result?.EpisodeNumber);
}
}
}

@ -6,8 +6,6 @@ namespace Jellyfin.Naming.Tests.TV
{
public class DailyEpisodeTests
{
[Theory]
[InlineData(@"/server/anything_1996.11.14.mp4", "anything", 1996, 11, 14)]
[InlineData(@"/server/anything_1996-11-14.mp4", "anything", 1996, 11, 14)]
@ -23,12 +21,12 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(options)
.Resolve(path, false);
Assert.Null(result.SeasonNumber);
Assert.Null(result.EpisodeNumber);
Assert.Equal(year, result.Year);
Assert.Equal(month, result.Month);
Assert.Equal(day, result.Day);
Assert.Equal(seriesName, result.SeriesName, true);
Assert.Null(result?.SeasonNumber);
Assert.Null(result?.EpisodeNumber);
Assert.Equal(year, result?.Year);
Assert.Equal(month, result?.Month);
Assert.Equal(day, result?.Day);
Assert.Equal(seriesName, result?.SeriesName, true);
}
}
}

@ -6,7 +6,6 @@ namespace Jellyfin.Naming.Tests.TV
{
public class EpisodeNumberWithoutSeasonTests
{
[Theory]
[InlineData(8, @"The Simpsons/The Simpsons.S25E08.Steal this episode.mp4")]
[InlineData(2, @"The Simpsons/The Simpsons - 02 - Ep Name.avi")]
@ -30,7 +29,7 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(options)
.Resolve(path, false);
Assert.Equal(episodeNumber, result.EpisodeNumber);
Assert.Equal(episodeNumber, result?.EpisodeNumber);
}
}
}

@ -1,4 +1,4 @@
using Emby.Naming.Common;
using Emby.Naming.Common;
using Emby.Naming.TV;
using Xunit;
@ -35,7 +35,6 @@ namespace Jellyfin.Naming.Tests.TV
// TODO: [InlineData("Watchmen (2019)/Watchmen 1x03 [WEBDL-720p][EAC3 5.1][h264][-TBS] - She Was Killed by Space Junk.mkv", "Watchmen (2019)", 1, 3)]
// TODO: [InlineData("/The.Legend.of.Condor.Heroes.2017.V2.web-dl.1080p.h264.aac-hdctv/The.Legend.of.Condor.Heroes.2017.E07.V2.web-dl.1080p.h264.aac-hdctv.mkv", "The Legend of Condor Heroes 2017", 1, 7)]
public void ParseEpisodesCorrectly(string path, string name, int season, int episode)
{
NamingOptions o = new NamingOptions();
EpisodePathParser p = new EpisodePathParser(o);

@ -19,9 +19,9 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(options)
.Resolve(path, false);
Assert.Equal(seasonNumber, result.SeasonNumber);
Assert.Equal(episodeNumber, result.EpisodeNumber);
Assert.Equal(seriesName, result.SeriesName, true);
Assert.Equal(seasonNumber, result?.SeasonNumber);
Assert.Equal(episodeNumber, result?.EpisodeNumber);
Assert.Equal(seriesName, result?.SeriesName, ignoreCase: true);
}
}
}

@ -59,7 +59,7 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(_namingOptions)
.Resolve(path, false);
Assert.Equal(expected, result.SeasonNumber);
Assert.Equal(expected, result?.SeasonNumber);
}
}
}

@ -31,9 +31,9 @@ namespace Jellyfin.Naming.Tests.TV
var result = new EpisodeResolver(options)
.Resolve(path, false);
Assert.Equal(seasonNumber, result.SeasonNumber);
Assert.Equal(episodeNumber, result.EpisodeNumber);
Assert.Equal(seriesName, result.SeriesName, true);
Assert.Equal(seasonNumber, result?.SeasonNumber);
Assert.Equal(episodeNumber, result?.EpisodeNumber);
Assert.Equal(seriesName, result?.SeriesName, true);
}
}
}

@ -25,8 +25,8 @@ namespace Jellyfin.Naming.Tests.Video
var result =
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv");
Assert.Equal("hsbs", result.Format3D);
Assert.Equal("Oblivion", result.Name);
Assert.Equal("hsbs", result?.Format3D);
Assert.Equal("Oblivion", result?.Name);
}
[Fact]

@ -12,7 +12,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiEdition1()
private void TestMultiEdition1()
{
var files = new[]
{
@ -28,7 +28,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -37,7 +36,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiEdition2()
private void TestMultiEdition2()
{
var files = new[]
{
@ -53,7 +52,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -76,7 +74,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -85,7 +82,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestLetterFolders()
private void TestLetterFolders()
{
var files = new[]
{
@ -104,7 +101,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(7, result.Count);
@ -114,7 +110,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersionLimit()
private void TestMultiVersionLimit()
{
var files = new[]
{
@ -134,7 +130,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -144,7 +139,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersionLimit2()
private void TestMultiVersionLimit2()
{
var files = new[]
{
@ -165,7 +160,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(9, result.Count);
@ -175,7 +169,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion3()
private void TestMultiVersion3()
{
var files = new[]
{
@ -192,7 +186,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(5, result.Count);
@ -202,7 +195,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion4()
private void TestMultiVersion4()
{
// Test for false positive
@ -221,7 +214,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(5, result.Count);
@ -231,7 +223,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion5()
private void TestMultiVersion5()
{
var files = new[]
{
@ -251,7 +243,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -264,7 +255,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion6()
private void TestMultiVersion6()
{
var files = new[]
{
@ -284,7 +275,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -297,7 +287,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion7()
private void TestMultiVersion7()
{
var files = new[]
{
@ -311,7 +301,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(2, result.Count);
@ -319,7 +308,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion8()
private void TestMultiVersion8()
{
// This is not actually supported yet
@ -340,7 +329,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -353,7 +341,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion9()
private void TestMultiVersion9()
{
// Test for false positive
@ -372,7 +360,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(5, result.Count);
@ -382,7 +369,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion10()
private void TestMultiVersion10()
{
var files = new[]
{
@ -396,7 +383,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -406,7 +392,7 @@ namespace Jellyfin.Naming.Tests.Video
// FIXME
// [Fact]
public void TestMultiVersion11()
private void TestMultiVersion11()
{
// Currently not supported but we should probably handle this.
@ -422,7 +408,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);

@ -368,11 +368,11 @@ namespace Jellyfin.Naming.Tests.Video
{
var files = new[]
{
new FileSystemMetadata{FullName = "Bad Boys (2006) part1.mkv", IsDirectory = false},
new FileSystemMetadata{FullName = "Bad Boys (2006) part2.mkv", IsDirectory = false},
new FileSystemMetadata{FullName = "300 (2006) part2", IsDirectory = true},
new FileSystemMetadata{FullName = "300 (2006) part3", IsDirectory = true},
new FileSystemMetadata{FullName = "300 (2006) part1", IsDirectory = true}
new FileSystemMetadata { FullName = "Bad Boys (2006) part1.mkv", IsDirectory = false },
new FileSystemMetadata { FullName = "Bad Boys (2006) part2.mkv", IsDirectory = false },
new FileSystemMetadata { FullName = "300 (2006) part2", IsDirectory = true },
new FileSystemMetadata { FullName = "300 (2006) part3", IsDirectory = true },
new FileSystemMetadata { FullName = "300 (2006) part1", IsDirectory = true }
};
var resolver = GetResolver();

@ -31,10 +31,10 @@ namespace Jellyfin.Naming.Tests.Video
var result =
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc");
Assert.Equal("Oblivion", result.Name);
Assert.Equal("Oblivion", result?.Name);
}
private void Test(string path, bool isStub, string stubType)
private void Test(string path, bool isStub, string? stubType)
{
var isStubResult = StubResolver.TryResolveFile(path, _namingOptions, out var stubTypeResult);

@ -9,9 +9,10 @@ namespace Jellyfin.Naming.Tests.Video
public class VideoListResolverTests
{
private readonly NamingOptions _namingOptions = new NamingOptions();
// FIXME
// [Fact]
public void TestStackAndExtras()
private void TestStackAndExtras()
{
// No stacking here because there is no part/disc/etc
var files = new[]
@ -45,7 +46,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(5, result.Count);
@ -74,7 +74,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -95,7 +94,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -116,7 +114,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -138,7 +135,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -159,7 +155,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -184,7 +179,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(5, result.Count);
@ -205,7 +199,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = true,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -227,7 +220,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = true,
FullName = i
}).ToList()).ToList();
Assert.Equal(2, result.Count);
@ -249,7 +241,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -271,7 +262,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -294,7 +284,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -317,7 +306,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(2, result.Count);
@ -337,7 +325,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -357,7 +344,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -378,7 +364,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -399,7 +384,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);
@ -422,7 +406,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Equal(4, result.Count);
@ -443,7 +426,6 @@ namespace Jellyfin.Naming.Tests.Video
{
IsDirectory = false,
FullName = i
}).ToList()).ToList();
Assert.Single(result);

@ -176,7 +176,6 @@ namespace Jellyfin.Naming.Tests.Video
};
}
[Theory]
[MemberData(nameof(GetResolveFileTestData))]
public void ResolveFile_ValidFileName_Success(VideoFileInfo expectedResult)
@ -184,17 +183,17 @@ namespace Jellyfin.Naming.Tests.Video
var result = new VideoResolver(_namingOptions).ResolveFile(expectedResult.Path);
Assert.NotNull(result);
Assert.Equal(result.Path, expectedResult.Path);
Assert.Equal(result.Container, expectedResult.Container);
Assert.Equal(result.Name, expectedResult.Name);
Assert.Equal(result.Year, expectedResult.Year);
Assert.Equal(result.ExtraType, expectedResult.ExtraType);
Assert.Equal(result.Format3D, expectedResult.Format3D);
Assert.Equal(result.Is3D, expectedResult.Is3D);
Assert.Equal(result.IsStub, expectedResult.IsStub);
Assert.Equal(result.StubType, expectedResult.StubType);
Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
Assert.Equal(result.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
Assert.Equal(result?.Path, expectedResult.Path);
Assert.Equal(result?.Container, expectedResult.Container);
Assert.Equal(result?.Name, expectedResult.Name);
Assert.Equal(result?.Year, expectedResult.Year);
Assert.Equal(result?.ExtraType, expectedResult.ExtraType);
Assert.Equal(result?.Format3D, expectedResult.Format3D);
Assert.Equal(result?.Is3D, expectedResult.Is3D);
Assert.Equal(result?.IsStub, expectedResult.IsStub);
Assert.Equal(result?.StubType, expectedResult.StubType);
Assert.Equal(result?.IsDirectory, expectedResult.IsDirectory);
Assert.Equal(result?.FileNameWithoutExtension, expectedResult.FileNameWithoutExtension);
}
}
}

Loading…
Cancel
Save