2011-11-22 07:55:09 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
|
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
|
|
|
|
{
|
2013-02-17 06:44:06 +01:00
|
|
|
|
class GetUpdateLogFixture : CoreTest
|
2011-11-22 07:55:09 +01:00
|
|
|
|
{
|
|
|
|
|
String UpdateLogFolder;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void setup()
|
|
|
|
|
{
|
|
|
|
|
WithTempAsAppPath();
|
|
|
|
|
|
2012-03-07 03:59:43 +01:00
|
|
|
|
UpdateLogFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateLogFolder();
|
2011-11-22 07:55:09 +01:00
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
|
2012-01-23 07:43:11 +01:00
|
|
|
|
.Returns(new []
|
2011-11-22 07:55:09 +01:00
|
|
|
|
{
|
|
|
|
|
"C:\\nzbdrone\\update\\2011.09.20-19-08.txt",
|
|
|
|
|
"C:\\nzbdrone\\update\\2011.10.20-20-08.txt",
|
|
|
|
|
"C:\\nzbdrone\\update\\2011.12.20-21-08.txt"
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(c => c.FolderExists(UpdateLogFolder))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void get_logs_should_return_empty_list_if_directory_doesnt_exist()
|
|
|
|
|
{
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
|
.Setup(c => c.FolderExists(UpdateLogFolder))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
|
|
|
|
var logs = Mocker.Resolve<UpdateProvider>().UpdateLogFile();
|
|
|
|
|
logs.Should().BeEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void get_logs_should_return_list_of_files_in_log_folder()
|
|
|
|
|
{
|
|
|
|
|
var logs = Mocker.Resolve<UpdateProvider>().UpdateLogFile();
|
|
|
|
|
logs.Should().HaveCount(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|