2013-07-19 03:47:55 +00:00
|
|
|
|
using System.Linq;
|
2013-07-15 23:53:06 +00:00
|
|
|
|
using FizzWare.NBuilder;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Marr.Data;
|
2013-07-22 06:31:51 +00:00
|
|
|
|
using Moq;
|
2013-07-15 23:53:06 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
|
|
|
|
using NzbDrone.Core.MediaFiles.EpisodeImport.Specifications;
|
|
|
|
|
using NzbDrone.Core.Parser.Model;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-07-26 05:41:38 +00:00
|
|
|
|
using NzbDrone.Test.Common;
|
2013-07-15 23:53:06 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.MediaFileTests.EpisodeImportTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class NotExistingFileSpecificationFixture : CoreTest<NotExistingFileSpecification>
|
|
|
|
|
{
|
|
|
|
|
private LocalEpisode _localEpisode;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode = new LocalEpisode
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(),
|
2013-07-15 23:53:06 +00:00
|
|
|
|
Size = 100
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_path_and_size_are_the_same()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
|
new EpisodeFile
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\30.rock.s01e01.avi".AsOsAgnostic(),
|
2013-07-15 23:53:06 +00:00
|
|
|
|
Size = 100
|
|
|
|
|
}))
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_filename_and_size_are_the_same()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
|
new EpisodeFile
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(),
|
2013-07-15 23:53:06 +00:00
|
|
|
|
Size = 100
|
|
|
|
|
}))
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_no_existing_file()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 0)
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_size_is_different()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
|
new EpisodeFile
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.avi".AsOsAgnostic(),
|
2013-07-15 23:53:06 +00:00
|
|
|
|
Size = 50
|
|
|
|
|
}))
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_true_if_file_names_are_different()
|
|
|
|
|
{
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
|
new EpisodeFile
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(),
|
2013-07-15 23:53:06 +00:00
|
|
|
|
Size = 100
|
|
|
|
|
}))
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeTrue();
|
|
|
|
|
}
|
2013-07-22 06:31:51 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_false_if_exact_path_exists_in_db()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<IMediaFileService>()
|
|
|
|
|
.Setup(s => s.Exists(It.IsAny<string>()))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
|
|
|
|
_localEpisode.Episodes = Builder<Episode>.CreateListOfSize(1)
|
|
|
|
|
.All()
|
|
|
|
|
.With(e => e.EpisodeFileId = 1)
|
|
|
|
|
.With(e => e.EpisodeFile = new LazyLoaded<EpisodeFile>(
|
|
|
|
|
new EpisodeFile
|
|
|
|
|
{
|
2013-07-26 05:41:38 +00:00
|
|
|
|
Path = @"C:\Test\30 Rock\Season 01\30.rock.s01e01.pilot.avi".AsOsAgnostic(),
|
2013-07-22 06:31:51 +00:00
|
|
|
|
Size = 100
|
|
|
|
|
}))
|
|
|
|
|
.Build()
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
Subject.IsSatisfiedBy(_localEpisode).Should().BeFalse();
|
|
|
|
|
}
|
2013-07-15 23:53:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|