|
|
@ -10,12 +10,6 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public class DiskProviderFixtureBase<TSubject> : TestBase<TSubject> where TSubject : class, IDiskProvider
|
|
|
|
public class DiskProviderFixtureBase<TSubject> : TestBase<TSubject> where TSubject : class, IDiskProvider
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[SetUp]
|
|
|
|
|
|
|
|
public void Setup()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DirectoryInfo GetFilledTempFolder()
|
|
|
|
public DirectoryInfo GetFilledTempFolder()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tempFolder = GetTempFilePath();
|
|
|
|
var tempFolder = GetTempFilePath();
|
|
|
@ -98,7 +92,7 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|
|
|
var source = GetFilledTempFolder();
|
|
|
|
var source = GetFilledTempFolder();
|
|
|
|
var destination = new DirectoryInfo(GetTempFilePath());
|
|
|
|
var destination = new DirectoryInfo(GetTempFilePath());
|
|
|
|
Subject.CopyFolder(source.FullName, destination.FullName);
|
|
|
|
Subject.CopyFolder(source.FullName, destination.FullName);
|
|
|
|
|
|
|
|
|
|
|
|
//Delete Random File
|
|
|
|
//Delete Random File
|
|
|
|
destination.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
|
|
|
|
destination.GetFiles("*.*", SearchOption.AllDirectories).First().Delete();
|
|
|
|
|
|
|
|
|
|
|
@ -172,7 +166,7 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|
|
|
public void empty_folder_should_return_folder_modified_date()
|
|
|
|
public void empty_folder_should_return_folder_modified_date()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var tempfolder = new DirectoryInfo(TempFolder);
|
|
|
|
var tempfolder = new DirectoryInfo(TempFolder);
|
|
|
|
Subject.FolderGetLastWriteUtc(TempFolder).Should().Be(tempfolder.LastWriteTimeUtc);
|
|
|
|
Subject.FolderGetLastWrite(TempFolder).Should().Be(tempfolder.LastWriteTimeUtc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -183,14 +177,14 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(testDir);
|
|
|
|
Directory.CreateDirectory(testDir);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.FolderSetLastWriteTimeUtc(TempFolder, DateTime.UtcNow.AddMinutes(-5));
|
|
|
|
Subject.FolderSetLastWriteTime(TempFolder, DateTime.UtcNow.AddMinutes(-5));
|
|
|
|
|
|
|
|
|
|
|
|
TestLogger.Info("Path is: {0}", testFile);
|
|
|
|
TestLogger.Info("Path is: {0}", testFile);
|
|
|
|
|
|
|
|
|
|
|
|
Subject.WriteAllText(testFile, "Test");
|
|
|
|
Subject.WriteAllText(testFile, "Test");
|
|
|
|
|
|
|
|
|
|
|
|
Subject.FolderGetLastWriteUtc(TempFolder).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-1));
|
|
|
|
Subject.FolderGetLastWrite(TempFolder).Should().BeOnOrAfter(DateTime.UtcNow.AddMinutes(-1));
|
|
|
|
Subject.FolderGetLastWriteUtc(TempFolder).Should().BeBefore(DateTime.UtcNow.AddMinutes(1));
|
|
|
|
Subject.FolderGetLastWrite(TempFolder).Should().BeBefore(DateTime.UtcNow.AddMinutes(1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
@ -234,11 +228,24 @@ namespace NzbDrone.Common.Test.DiskProviderTests
|
|
|
|
Subject.InheritFolderPermissions(testFile);
|
|
|
|
Subject.InheritFolderPermissions(testFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
|
|
public void should_be_set_last_file_write()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var testFile = GetTempFilePath();
|
|
|
|
|
|
|
|
Subject.WriteAllText(testFile, new Guid().ToString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var lastWriteTime = new DateTime(2012, 1, 2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Subject.FileSetLastWriteTime(testFile, lastWriteTime);
|
|
|
|
|
|
|
|
Subject.FileGetLastWrite(testFile).Should().Be(lastWriteTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[Test]
|
|
|
|
[Explicit]
|
|
|
|
[Explicit]
|
|
|
|
public void check_last_write()
|
|
|
|
public void check_last_write()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Console.WriteLine(Subject.FolderGetLastWriteUtc(GetFilledTempFolder().FullName));
|
|
|
|
Console.WriteLine(Subject.FolderGetLastWrite(GetFilledTempFolder().FullName));
|
|
|
|
Console.WriteLine(GetFilledTempFolder().LastWriteTimeUtc);
|
|
|
|
Console.WriteLine(GetFilledTempFolder().LastWriteTimeUtc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|