Merge branch 'master' of git://github.com/kayone/NzbDrone

pull/6/head
Mark McDowall 13 years ago
commit 00b1e4bb12

@ -166,6 +166,40 @@ namespace NzbDrone.Core.Test
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()

@ -75,7 +75,7 @@ namespace NzbDrone.Core
var logRepository = new SimpleRepository(logDbProvider, SimpleRepositoryOptions.RunMigrations);
//dbProvider.ExecuteQuery(new QueryCommand("VACUUM", dbProvider));
dbProvider.Log = new NlogWriter();
//dbProvider.Log = new NlogWriter();
_kernel.Bind<QualityProvider>().ToSelf().InSingletonScope();
_kernel.Bind<TvDbProvider>().ToSelf().InTransientScope();

@ -72,11 +72,13 @@ namespace NzbDrone.Core.Providers
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>();

@ -108,6 +108,7 @@ namespace NzbDrone.Core.Providers
public virtual Series FindSeries(string title)
{
//TODO:Add series alias support here. if a series is not found in the repo should be tried using its aliases
var normalizeTitle = Parser.NormalizeTitle(title);
return _repository.Single<Series>(s => s.CleanTitle == normalizeTitle);
}

@ -9,10 +9,10 @@
<parameter name="ThreadName" layout="${threadname}" xsi:type="NLogViewerParameterInfo" />
</target>
<target name="file" xsi:type="File"
<target name="file" xsi:type="File" keepFileOpen="true" openFileCacheTimeout="1"
layout="${longdate} [${level}] ${logger}: ${message} ${exception:ToString}"
fileName="${basedir}/App_Data/logs/${shortdate}.txt" />
<target name ="xmlFile" xsi:type="File"
<target name ="xmlFile" xsi:type="File" keepFileOpen="true" openFileCacheTimeout="1"
fileName="${basedir}/App_Data/logs/${shortdate}.xml"
layout="${log4jxmlevent:includeSourceInfo=true:includeCallSite=true:includeMDC=true:appInfo=true:includeNDC=true:includeNLogData=true}"/>
</targets>

Loading…
Cancel
Save