2012-08-29 17:34:51 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Moq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
2013-05-13 02:36:23 +02:00
|
|
|
|
using NzbDrone.Core.MediaFiles;
|
2012-08-29 17:34:51 +02:00
|
|
|
|
using NzbDrone.Core.Providers;
|
2013-03-07 02:51:47 +01:00
|
|
|
|
|
2012-08-29 17:34:51 +02:00
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.DiskScanProviderTests
|
|
|
|
|
{
|
2013-03-28 23:07:09 +01:00
|
|
|
|
|
2013-04-16 02:08:06 +02:00
|
|
|
|
public class GetVideoFilesFixture : CoreTest<DiskScanService>
|
2012-08-29 17:34:51 +02:00
|
|
|
|
{
|
|
|
|
|
private string[] _files;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-04-16 02:08:06 +02:00
|
|
|
|
_files = new[]
|
2012-08-29 17:34:51 +02:00
|
|
|
|
{
|
|
|
|
|
@"C:\Test\30 Rock1.mkv",
|
|
|
|
|
@"C:\Test\30 Rock2.avi",
|
|
|
|
|
@"C:\Test\30 Rock3.mp4",
|
|
|
|
|
@"C:\Test\30 Rock4.wmv",
|
|
|
|
|
@"C:\Test\movie.exe"
|
|
|
|
|
};
|
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2012-08-29 17:34:51 +02:00
|
|
|
|
.Setup(s => s.GetFiles(It.IsAny<String>(), SearchOption.AllDirectories))
|
|
|
|
|
.Returns(_files);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_check_all_directories()
|
|
|
|
|
{
|
|
|
|
|
var path = @"C:\Test\";
|
|
|
|
|
|
2013-04-16 02:08:06 +02:00
|
|
|
|
Subject.GetVideoFiles(path);
|
2012-08-29 17:34:51 +02:00
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
2012-08-29 17:34:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_check_all_directories_when_allDirectories_is_true()
|
|
|
|
|
{
|
|
|
|
|
var path = @"C:\Test\";
|
|
|
|
|
|
2013-04-16 02:08:06 +02:00
|
|
|
|
Subject.GetVideoFiles(path, true);
|
2012-08-29 17:34:51 +02:00
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Once());
|
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Never());
|
2012-08-29 17:34:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_check_top_level_directory_only_when_allDirectories_is_false()
|
|
|
|
|
{
|
|
|
|
|
var path = @"C:\Test\";
|
|
|
|
|
|
2013-04-16 02:08:06 +02:00
|
|
|
|
Subject.GetVideoFiles(path, false);
|
2012-08-29 17:34:51 +02:00
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.AllDirectories), Times.Never());
|
|
|
|
|
Mocker.GetMock<IDiskProvider>().Verify(s => s.GetFiles(path, SearchOption.TopDirectoryOnly), Times.Once());
|
2012-08-29 17:34:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void should_return_video_files_only()
|
|
|
|
|
{
|
|
|
|
|
var path = @"C:\Test\";
|
|
|
|
|
|
2013-04-16 02:08:06 +02:00
|
|
|
|
Subject.GetVideoFiles(path).Should().HaveCount(4);
|
2012-08-29 17:34:51 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|