1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-26 17:47:08 +00:00

Fixed bug when a file that wasn't parsable would try to be imported

This commit is contained in:
kay.one 2011-05-19 19:12:36 -07:00
parent 90c6b78e8c
commit 69406a95d4
2 changed files with 37 additions and 1 deletions

View file

@ -166,6 +166,40 @@ public void import_existing_season_file()
Assert.IsNull(result);
}
[Test]
[Description("Verifies that a un-parsable file isn't imported")]
public void import_unparsable_file()
{
//Arrange
/////////////////////////////////////////
//Constants
const string fileName = @"WEEDS.avi";
const int size = 12345;
//Fakes
var fakeSeries = Builder<Series>.CreateNew().Build();
//Mocks
var mocker = new AutoMoqer();
mocker.GetMock<IRepository>(MockBehavior.Strict)
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
mocker.GetMock<DiskProvider>()
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
//Act
var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
//Assert
mocker.VerifyAllMocks();
Assert.IsNull(result);
ExceptionVerification.ExcpectedWarns(1);
}
[Test]
[Description("Verifies that a new file imported properly")]
public void import_sample_file()

View file

@ -72,11 +72,13 @@ public virtual EpisodeFile ImportFile(Series series, string filePath)
if (!_repository.Exists<EpisodeFile>(e => e.Path == Parser.NormalizePath(filePath)))
{
var parseResult = Parser.ParseEpisodeInfo(filePath);
parseResult.CleanTitle = series.Title;//replaces the nasty path as title to help with logging
if (parseResult == null)
return null;
parseResult.CleanTitle = series.Title;//replaces the nasty path as title to help with logging
//Stores the list of episodes to add to the EpisodeFile
var episodes = new List<Episode>();