1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-03-05 15:15:59 +02:00
Sonarr/NzbDrone.Core.Test/UpdateTests/GetUpdateLogFixture.cs

58 lines
1.5 KiB
C#
Raw Normal View History

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