Removed SharedLiveTemplates.xml.

Cleaned up PostDownloadProvider, added more tests.
This commit is contained in:
Mark McDowall 2011-10-17 20:08:26 -07:00
commit e87cdbde44
4 changed files with 176 additions and 47 deletions

View file

@ -47,7 +47,7 @@ namespace NzbDrone.Core.Test
.Have(c => c.PostDownloadStatus = PostDownloadStatusType.Unknown)
.Build();
var expectedEpisodesNumbers = fakeEpisodes.Select(e => e.EpisodeId);
var expectedEpisodesNumbers = fakeEpisodes.Select(e => e.EpisodeId).ToList();
mocker.GetMock<SeriesProvider>().Setup(s => s.FindSeries("officeus")).Returns(fakeSeries);
mocker.GetMock<EpisodeProvider>().Setup(s => s.GetEpisodesByParseResult(It.IsAny<EpisodeParseResult>(), false)).Returns(fakeEpisodes);
@ -124,6 +124,8 @@ namespace NzbDrone.Core.Test
[TestCase(PostDownloadStatusType.ParseError, 21)]
[TestCase(PostDownloadStatusType.Unknown, 10)]
[TestCase(PostDownloadStatusType.Processed, 0)]
[TestCase(PostDownloadStatusType.InvalidEpisode, 25)]
[TestCase(PostDownloadStatusType.NoError, 0)]
public void GetPrefixLength(PostDownloadStatusType postDownloadStatus, int expected)
{
//Setup
@ -244,5 +246,107 @@ namespace NzbDrone.Core.Test
//Assert
mocker.VerifyAllMocks();
}
[TestCase("_NzbDrone_InvalidEpisode_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidEpisode)]
[TestCase("_NzbDrone_InvalidSeries_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidSeries)]
[TestCase("_NzbDrone_ParseError_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.ParseError)]
[TestCase("_UNPACK_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Unpacking)]
[TestCase("_FAILED_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Failed)]
[TestCase("_NzbDrone_The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Unknown)]
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.NoError)]
public void GetPostDownloadStatusForFolder_should_return_a_proper_match(string folderName, PostDownloadStatusType expectedStatus)
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
//Act
var result = mocker.Resolve<PostDownloadProvider>().GetPostDownloadStatusForFolder(folderName);
//Assert
result.Should().Be(expectedStatus);
}
[TestCase("_NzbDrone_InvalidEpisode_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidSeries)]
[TestCase("_NzbDrone_InvalidSeries_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidEpisode)]
[TestCase("_NzbDrone_ParseError_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidSeries)]
[TestCase("_UNPACK_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidEpisode)]
[TestCase("_FAILED_", "The Office (US) - S01E01 - Title", PostDownloadStatusType.ParseError)]
[TestCase("_NzbDrone_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.ParseError)]
public void GetNewFolderNameWithPostDownloadStatus_should_return_a_string_with_the_error_removing_existing_error(string existingErrorString, string folderName, PostDownloadStatusType postDownloadStatus)
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
var di = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), existingErrorString + folderName));
var expectedFolderName = String.Format("_NzbDrone_{0}_{1}", postDownloadStatus.ToString(), folderName);
var expectedResult = Path.Combine(Directory.GetCurrentDirectory(), expectedFolderName);
//Act
var result = mocker.Resolve<PostDownloadProvider>().GetNewFolderNameWithPostDownloadStatus(di, postDownloadStatus);
//Assert
result.Should().Be(expectedResult);
}
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidSeries)]
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.InvalidEpisode)]
[TestCase("The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.ParseError)]
public void GetNewFolderNameWithPostDownloadStatus_should_return_a_string_with_the_error(string folderName, PostDownloadStatusType postDownloadStatus)
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
var di = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), folderName));
var expectedFolderName = String.Format("_NzbDrone_{0}_{1}", postDownloadStatus.ToString(), folderName);
var expectedResult = Path.Combine(Directory.GetCurrentDirectory(), expectedFolderName);
//Act
var result = mocker.Resolve<PostDownloadProvider>().GetNewFolderNameWithPostDownloadStatus(di, postDownloadStatus);
//Assert
result.Should().Be(expectedResult);
}
[TestCase("_NzbDrone_ParseError_", "The Office (US) - S01E01 - Episode Title")]
[TestCase("", "The Office (US) - S01E01 - Episode Title")]
public void GetNewFolderNameWithPostDownloadStatus_should_return_a_path_with_a_unknown_error(string existingError, string folderName)
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
var di = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), folderName));
var expectedFolderName = String.Format("_NzbDrone_{0}", folderName);
var expectedResult = Path.Combine(Directory.GetCurrentDirectory(), expectedFolderName);
//Act
var result = mocker.Resolve<PostDownloadProvider>().GetNewFolderNameWithPostDownloadStatus(di, PostDownloadStatusType.Unknown);
//Assert
result.Should().Be(expectedResult);
}
[TestCase("_NzbDrone_ParseError_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.NoError)]
[TestCase("", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.NoError)]
[TestCase("_NzbDrone_ParseError_", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Processed)]
[TestCase("", "The Office (US) - S01E01 - Episode Title", PostDownloadStatusType.Processed)]
public void GetNewFolderNameWithPostDownloadStatus_should_return_a_path_with_no_error(string existingError, string folderName, PostDownloadStatusType postDownloadStatus)
{
//Setup
var mocker = new AutoMoqer(MockBehavior.Strict);
var di = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), folderName));
var expectedFolderName = folderName;
var expectedResult = Path.Combine(Directory.GetCurrentDirectory(), expectedFolderName);
//Act
var result = mocker.Resolve<PostDownloadProvider>().GetNewFolderNameWithPostDownloadStatus(di, postDownloadStatus);
//Assert
result.Should().Be(expectedResult);
}
}
}