2011-11-22 09:55:09 +03: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 08:44:06 +03:00
|
|
|
class GetUpdateLogFixture : CoreTest
|
2011-11-22 09:55:09 +03:00
|
|
|
{
|
|
|
|
String UpdateLogFolder;
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void setup()
|
|
|
|
{
|
|
|
|
WithTempAsAppPath();
|
|
|
|
|
2012-03-07 05:59:43 +03:00
|
|
|
UpdateLogFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateLogFolder();
|
2011-11-22 09:55:09 +03:00
|
|
|
|
|
|
|
Mocker.GetMock<DiskProvider>()
|
|
|
|
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
|
2012-01-23 09:43:11 +03:00
|
|
|
.Returns(new []
|
2011-11-22 09:55:09 +03: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|