sonarr-repo-only/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs

58 lines
1.6 KiB
C#
Raw Normal View History

2013-04-13 23:57:10 +00:00
using System;
2011-11-22 06:55:09 +00:00
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Test.Framework;
2013-04-13 23:57:10 +00:00
namespace NzbDrone.Core.Test.UpdateTests
2011-11-22 06:55:09 +00:00
{
class GetUpdateLogFixture : CoreTest
2011-11-22 06:55:09 +00:00
{
String UpdateLogFolder;
[SetUp]
public void setup()
{
WithTempAsAppPath();
UpdateLogFolder = Mocker.GetMock<EnvironmentProvider>().Object.GetUpdateLogFolder();
2011-11-22 06:55:09 +00:00
Mocker.GetMock<DiskProvider>()
.Setup(c => c.GetFiles(UpdateLogFolder, SearchOption.TopDirectoryOnly))
.Returns(new []
2011-11-22 06:55:09 +00: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);
2013-04-13 23:57:10 +00:00
var logs = Mocker.Resolve<UpdateService>().UpdateLogFile();
2011-11-22 06:55:09 +00:00
logs.Should().BeEmpty();
}
[Test]
public void get_logs_should_return_list_of_files_in_log_folder()
{
2013-04-13 23:57:10 +00:00
var logs = Mocker.Resolve<UpdateService>().UpdateLogFile();
2011-11-22 06:55:09 +00:00
logs.Should().HaveCount(3);
}
}
}