2011-10-23 21:31:17 +03:00
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
2011-11-14 03:22:18 +03:00
|
|
|
|
2011-10-23 21:31:17 +03:00
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
|
|
|
using NzbDrone.Common;
|
2011-11-13 21:16:31 +03:00
|
|
|
using NzbDrone.Test.Common;
|
2011-10-23 21:31:17 +03:00
|
|
|
using NzbDrone.Update.Providers;
|
|
|
|
|
|
|
|
namespace NzbDrone.Update.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2011-11-13 23:31:02 +03:00
|
|
|
class UpdateProviderVerifyFixture : TestBase
|
2011-10-23 21:31:17 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup()
|
|
|
|
{
|
2012-03-07 05:59:43 +03:00
|
|
|
Mocker.GetMock<EnvironmentProvider>()
|
2011-10-23 21:31:17 +03:00
|
|
|
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
|
2011-11-13 08:19:19 +03:00
|
|
|
|
2012-03-07 05:59:43 +03:00
|
|
|
Mocker.GetMock<EnvironmentProvider>()
|
2011-11-13 08:19:19 +03:00
|
|
|
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
|
2011-10-23 21:31:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase(null)]
|
|
|
|
[TestCase("")]
|
|
|
|
[TestCase(" ")]
|
2011-11-13 07:07:06 +03:00
|
|
|
public void update_should_throw_target_folder_is_blank(string target)
|
2011-10-23 21:31:17 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
Assert.Throws<ArgumentException>(() => Mocker.Resolve<UpdateProvider>().Start(target))
|
2011-10-23 21:31:17 +03:00
|
|
|
.Message.Should().StartWith("Target folder can not be null or empty");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2011-11-13 07:07:06 +03:00
|
|
|
public void update_should_throw_if_target_folder_doesnt_exist()
|
2011-10-23 21:31:17 +03:00
|
|
|
{
|
|
|
|
string targetFolder = "c:\\NzbDrone\\";
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
|
2011-10-23 21:31:17 +03:00
|
|
|
.Message.Should().StartWith("Target folder doesn't exist");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2011-11-13 07:07:06 +03:00
|
|
|
public void update_should_throw_if_update_folder_doesnt_exist()
|
2011-10-23 21:31:17 +03:00
|
|
|
{
|
2011-11-13 07:07:06 +03:00
|
|
|
const string sandboxFolder = @"C:\Temp\NzbDrone_update\nzbdrone";
|
2011-10-23 21:31:17 +03:00
|
|
|
const string targetFolder = "c:\\NzbDrone\\";
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<DiskProvider>()
|
2011-10-23 21:31:17 +03:00
|
|
|
.Setup(c => c.FolderExists(targetFolder))
|
|
|
|
.Returns(true);
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.GetMock<DiskProvider>()
|
2011-10-23 21:31:17 +03:00
|
|
|
.Setup(c => c.FolderExists(sandboxFolder))
|
|
|
|
.Returns(false);
|
|
|
|
|
2011-12-15 07:15:53 +03:00
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<UpdateProvider>().Start(targetFolder))
|
2011-10-23 21:31:17 +03:00
|
|
|
.Message.Should().StartWith("Update folder doesn't exist");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|