The Free Software Media System - Server Backend & API
Add tests for Recordinghelper
Bond_009a9f44c21eb27
diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.csindex 142c59542a..32245f899e 100644--- a/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs+++ b/Emby.Server.Implementations/LiveTv/EmbyTV/RecordingHelper.cs@@ -6,7 +6,7 @@ using MediaBrowser.Controller.LiveTv;namespace Emby.Server.Implementations.LiveTv.EmbyTV{- internal class RecordingHelper+ internal static class RecordingHelper{public static DateTime GetStartTime(TimerInfo timer){@@ -70,17 +70,7 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTVprivate static string GetDateString(DateTime date){- date = date.ToLocalTime();-- return string.Format(- CultureInfo.InvariantCulture,- "{0}_{1}_{2}_{3}_{4}_{5}",- date.Year.ToString("0000", CultureInfo.InvariantCulture),- date.Month.ToString("00", CultureInfo.InvariantCulture),- date.Day.ToString("00", CultureInfo.InvariantCulture),- date.Hour.ToString("00", CultureInfo.InvariantCulture),- date.Minute.ToString("00", CultureInfo.InvariantCulture),- date.Second.ToString("00", CultureInfo.InvariantCulture));+ return date.ToLocalTime().ToString("yyyy_MM_dd_HH_mm_ss", CultureInfo.InvariantCulture);}}}diff --git a/jellyfin.ruleset b/jellyfin.rulesetindex 19c0a08b23..6ba36d35cc 100644--- a/jellyfin.ruleset+++ b/jellyfin.ruleset@@ -43,6 +43,8 @@or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token --><Rule Id="CA2016" Action="Error" />+ <!-- disable warning CA1024: Use properties where appropriate -->+ <Rule Id="CA1024" Action="Info" /><!-- disable warning CA1031: Do not catch general exception types --><Rule Id="CA1031" Action="Info" /><!-- disable warning CA1032: Implement standard exception constructors -->diff --git a/tests/Jellyfin.Server.Implementations.Tests/LiveTv/RecordingHelperTests.cs b/tests/Jellyfin.Server.Implementations.Tests/LiveTv/RecordingHelperTests.csnew file mode 100644index 0000000000..e8b93b437b--- /dev/null+++ b/tests/Jellyfin.Server.Implementations.Tests/LiveTv/RecordingHelperTests.cs@@ -0,0 +1,115 @@+using System;+using System.Collections.Generic;+using Emby.Server.Implementations.LiveTv.EmbyTV;+using MediaBrowser.Controller.LiveTv;+using Xunit;++namespace Jellyfin.Server.Implementations.Tests.LiveTv+{+ public static class RecordingHelperTests+ {+ public static IEnumerable<object[]> GetRecordingName_Success_TestData()+ {+ yield return new object[]+ {+ "The Incredibles 2020_04_20_21_06_00",+ new TimerInfo+ {+ Name = "The Incredibles",+ StartDate = new DateTime(2020, 4, 20, 21, 6, 0, DateTimeKind.Local),+ IsMovie = true+ }+ };++ yield return new object[]+ {+ "The Incredibles (2004)",+ new TimerInfo+ {+ Name = "The Incredibles",+ IsMovie = true,+ ProductionYear = 2004+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory 2020_04_20_21_06_00",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ StartDate = new DateTime(2020, 4, 20, 21, 6, 0, DateTimeKind.Local),+ IsProgramSeries = true,+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory S12E10",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ IsProgramSeries = true,+ SeasonNumber = 12,+ EpisodeNumber = 10+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory S12E10 The VCR Illumination",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ IsProgramSeries = true,+ SeasonNumber = 12,+ EpisodeNumber = 10,+ EpisodeTitle = "The VCR Illumination"+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory 2018-12-06",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ IsProgramSeries = true,+ OriginalAirDate = new DateTime(2018, 12, 6)+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory 2018-12-06 - The VCR Illumination",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ IsProgramSeries = true,+ OriginalAirDate = new DateTime(2018, 12, 6),+ EpisodeTitle = "The VCR Illumination"+ }+ };++ yield return new object[]+ {+ "The Big Bang Theory 2018_12_06_21_06_00 - The VCR Illumination",+ new TimerInfo+ {+ Name = "The Big Bang Theory",+ StartDate = new DateTime(2018, 12, 6, 21, 6, 0, DateTimeKind.Local),+ IsProgramSeries = true,+ OriginalAirDate = new DateTime(2018, 12, 6),+ EpisodeTitle = "The VCR Illumination"+ }+ };+ }++ [Theory]+ [MemberData(nameof(GetRecordingName_Success_TestData))]+ public static void GetRecordingName_Success(string expected, TimerInfo timerInfo)+ {+ Assert.Equal(expected, RecordingHelper.GetRecordingName(timerInfo));+ }+ }+}