2013-04-14 01:57:10 +02:00
|
|
|
using System;
|
2011-11-22 07:55:09 +01:00
|
|
|
using System.IO;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2013-05-20 02:30:02 +02:00
|
|
|
using NzbDrone.Core.Update;
|
2011-11-22 07:55:09 +01:00
|
|
|
|
2013-04-14 01:57:10 +02:00
|
|
|
namespace NzbDrone.Core.Test.UpdateTests
|
2011-11-22 07:55:09 +01:00
|
|
|
{
|
2013-04-16 06:52:41 +02:00
|
|
|
public class GetUpdateLogFixture : CoreTest<UpdateService>
|
2011-11-22 07:55:09 +01:00
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
String _updateLogFolder;
|
2011-11-22 07:55:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
2013-04-15 03:41:39 +02:00
|
|
|
public void Setup()
|
2011-11-22 07:55:09 +01:00
|
|
|
{
|
|
|
|
WithTempAsAppPath();
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
_updateLogFolder = Mocker.GetMock<IEnvironmentProvider>().Object.GetUpdateLogFolder();
|
2011-11-22 07:55:09 +01:00
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2013-04-15 03:41:39 +02:00
|
|
|
.Setup(c => c.GetFiles(_updateLogFolder, SearchOption.TopDirectoryOnly))
|
|
|
|
.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"
|
|
|
|
});
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2013-04-15 03:41:39 +02:00
|
|
|
.Setup(c => c.FolderExists(_updateLogFolder))
|
2011-11-22 07:55:09 +01:00
|
|
|
.Returns(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void get_logs_should_return_empty_list_if_directory_doesnt_exist()
|
|
|
|
{
|
2013-05-11 01:53:50 +02:00
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2013-04-15 03:41:39 +02:00
|
|
|
.Setup(c => c.FolderExists(_updateLogFolder))
|
2011-11-22 07:55:09 +01:00
|
|
|
.Returns(false);
|
|
|
|
|
2013-04-15 03:41:39 +02:00
|
|
|
Subject.GetUpdateLogFiles().Should().BeEmpty();
|
2011-11-22 07:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void get_logs_should_return_list_of_files_in_log_folder()
|
|
|
|
{
|
2013-04-15 03:41:39 +02:00
|
|
|
var logs = Subject.GetUpdateLogFiles();
|
2011-11-22 07:55:09 +01:00
|
|
|
logs.Should().HaveCount(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|