|
|
|
@ -71,6 +71,59 @@ namespace NzbDrone.Core.Test
|
|
|
|
|
Assert.AreNotEqual(new DateTime(), result.DateAdded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[Description("Verifies that a new file imported properly")]
|
|
|
|
|
public void import_new_daily_file()
|
|
|
|
|
{
|
|
|
|
|
//Arrange
|
|
|
|
|
/////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
//Constants
|
|
|
|
|
const string fileName = @"2011.01.10 - Denis Leary - HD TV.mkv";
|
|
|
|
|
DateTime airDate = new DateTime(2011, 01, 10);
|
|
|
|
|
const int size = 12345;
|
|
|
|
|
//Fakes
|
|
|
|
|
var fakeSeries = Builder<Series>.CreateNew().Build();
|
|
|
|
|
var fakeEpisode = Builder<Episode>.CreateNew().With(c => c.SeriesId = fakeSeries.SeriesId).Build();
|
|
|
|
|
|
|
|
|
|
//Mocks
|
|
|
|
|
var mocker = new AutoMoqer();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<IRepository>()
|
|
|
|
|
.Setup(r => r.Exists(It.IsAny<Expression<Func<EpisodeFile, Boolean>>>())).Returns(false).Verifiable();
|
|
|
|
|
mocker.GetMock<IRepository>()
|
|
|
|
|
.Setup(r => r.Add(It.IsAny<EpisodeFile>())).Returns(0).Verifiable();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<EpisodeProvider>()
|
|
|
|
|
.Setup(e => e.GetEpisode(fakeSeries.SeriesId, airDate)).Returns(fakeEpisode).
|
|
|
|
|
Verifiable();
|
|
|
|
|
|
|
|
|
|
mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(e => e.GetSize(fileName)).Returns(size).Verifiable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Act
|
|
|
|
|
var result = mocker.Resolve<MediaFileProvider>().ImportFile(fakeSeries, fileName);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
Assert.IsNotNull(result);
|
|
|
|
|
mocker.GetMock<IRepository>().VerifyAll();
|
|
|
|
|
mocker.GetMock<IRepository>().Verify(r => r.Add(result), Times.Once());
|
|
|
|
|
mocker.GetMock<EpisodeProvider>().VerifyAll();
|
|
|
|
|
mocker.GetMock<DiskProvider>().VerifyAll();
|
|
|
|
|
|
|
|
|
|
//Currently can't verify this since the list of episodes are loaded
|
|
|
|
|
//Dynamically by SubSonic
|
|
|
|
|
//Assert.AreEqual(fakeEpisode, result.Episodes[0]);
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual(fakeEpisode.SeriesId, result.SeriesId);
|
|
|
|
|
Assert.AreEqual(QualityTypes.BDRip, result.Quality);
|
|
|
|
|
Assert.AreEqual(Parser.NormalizePath(fileName), result.Path);
|
|
|
|
|
Assert.AreEqual(size, result.Size);
|
|
|
|
|
Assert.AreEqual(false, result.Proper);
|
|
|
|
|
Assert.AreNotEqual(new DateTime(), result.DateAdded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
[Description("Verifies that an existing file will skip import")]
|
|
|
|
|