2011-10-24 07:54:09 +02:00
|
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
2011-11-13 19:16:31 +01:00
|
|
|
|
using NzbDrone.Test.Common;
|
2011-10-24 07:54:09 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Common.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2011-11-13 19:16:31 +01:00
|
|
|
|
public class DiskProviderTests : TestBase
|
2011-10-24 07:54:09 +02:00
|
|
|
|
{
|
|
|
|
|
DirectoryInfo BinFolder;
|
|
|
|
|
DirectoryInfo BinFolderCopy;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
|
|
|
|
var binRoot = new DirectoryInfo(Directory.GetCurrentDirectory()).Parent.Parent;
|
|
|
|
|
BinFolder = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin"));
|
|
|
|
|
BinFolderCopy = new DirectoryInfo(Path.Combine(binRoot.FullName, "bin_copy"));
|
|
|
|
|
|
|
|
|
|
if (BinFolderCopy.Exists)
|
|
|
|
|
{
|
|
|
|
|
BinFolderCopy.Delete(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void CopyFolder_should_copy_folder()
|
|
|
|
|
{
|
|
|
|
|
//Act
|
|
|
|
|
var diskProvider = new DiskProvider();
|
|
|
|
|
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
BinFolder.Refresh();
|
|
|
|
|
BinFolderCopy.Refresh();
|
|
|
|
|
|
|
|
|
|
BinFolder.GetFiles("*.*", SearchOption.AllDirectories)
|
|
|
|
|
.Should().HaveSameCount(BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void CopyFolder_should_overright_existing_folder()
|
|
|
|
|
{
|
|
|
|
|
//Act
|
|
|
|
|
var diskProvider = new DiskProvider();
|
|
|
|
|
|
|
|
|
|
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
|
|
|
|
|
|
|
|
|
//Delete Random File
|
|
|
|
|
BinFolderCopy.GetFiles().First().Delete();
|
|
|
|
|
|
|
|
|
|
diskProvider.CopyDirectory(BinFolder.FullName, BinFolderCopy.FullName);
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
BinFolder.Refresh();
|
|
|
|
|
BinFolderCopy.Refresh();
|
|
|
|
|
|
|
|
|
|
BinFolder.GetFiles("*.*", SearchOption.AllDirectories)
|
|
|
|
|
.Should().HaveSameCount(BinFolderCopy.GetFiles("*.*", SearchOption.AllDirectories));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|