2013-05-16 02:52:54 +02:00
|
|
|
|
using System;
|
2011-10-23 20:31:17 +02:00
|
|
|
|
using System.IO;
|
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using NzbDrone.Common;
|
2011-11-13 19:16:31 +01:00
|
|
|
|
using NzbDrone.Test.Common;
|
2013-05-21 06:03:05 +02:00
|
|
|
|
using NzbDrone.Update.UpdateEngine;
|
2011-10-23 20:31:17 +02:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Update.Test
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2013-04-16 06:52:41 +02:00
|
|
|
|
public class UpdateProviderVerifyFixture : TestBase
|
2011-10-23 20:31:17 +02:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
|
|
|
|
{
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IEnvironmentProvider>()
|
2011-11-13 06:19:19 +01:00
|
|
|
|
.Setup(c => c.SystemTemp).Returns(@"C:\Temp\");
|
2011-10-23 20:31:17 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase(null)]
|
|
|
|
|
[TestCase("")]
|
|
|
|
|
[TestCase(" ")]
|
2011-11-13 05:07:06 +01:00
|
|
|
|
public void update_should_throw_target_folder_is_blank(string target)
|
2011-10-23 20:31:17 +02:00
|
|
|
|
{
|
2013-05-21 06:03:05 +02:00
|
|
|
|
Assert.Throws<ArgumentException>(() => Mocker.Resolve<InstallUpdateService>().Start(target))
|
2011-10-23 20:31:17 +02:00
|
|
|
|
.Message.Should().StartWith("Target folder can not be null or empty");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-11-13 05:07:06 +01:00
|
|
|
|
public void update_should_throw_if_target_folder_doesnt_exist()
|
2011-10-23 20:31:17 +02:00
|
|
|
|
{
|
|
|
|
|
string targetFolder = "c:\\NzbDrone\\";
|
|
|
|
|
|
2013-05-21 06:03:05 +02:00
|
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<InstallUpdateService>().Start(targetFolder))
|
2011-10-23 20:31:17 +02:00
|
|
|
|
.Message.Should().StartWith("Target folder doesn't exist");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2011-11-13 05:07:06 +01:00
|
|
|
|
public void update_should_throw_if_update_folder_doesnt_exist()
|
2011-10-23 20:31:17 +02:00
|
|
|
|
{
|
2011-11-13 05:07:06 +01:00
|
|
|
|
const string sandboxFolder = @"C:\Temp\NzbDrone_update\nzbdrone";
|
2011-10-23 20:31:17 +02:00
|
|
|
|
const string targetFolder = "c:\\NzbDrone\\";
|
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2011-10-23 20:31:17 +02:00
|
|
|
|
.Setup(c => c.FolderExists(targetFolder))
|
|
|
|
|
.Returns(true);
|
|
|
|
|
|
2013-05-11 01:53:50 +02:00
|
|
|
|
Mocker.GetMock<IDiskProvider>()
|
2011-10-23 20:31:17 +02:00
|
|
|
|
.Setup(c => c.FolderExists(sandboxFolder))
|
|
|
|
|
.Returns(false);
|
|
|
|
|
|
2013-05-21 06:03:05 +02:00
|
|
|
|
Assert.Throws<DirectoryNotFoundException>(() => Mocker.Resolve<InstallUpdateService>().Start(targetFolder))
|
2011-10-23 20:31:17 +02:00
|
|
|
|
.Message.Should().StartWith("Update folder doesn't exist");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|