Radarr/NzbDrone.Update.Test/UpdateProviderVerifyTest.cs

65 lines
1.9 KiB
C#
Raw Normal View History

2011-10-23 18:31:17 +00:00
// ReSharper disable InconsistentNaming
using System;
using System.IO;
using AutoMoq;
using FluentAssertions;
2011-10-23 22:44:37 +00:00
using Moq;
2011-10-23 18:31:17 +00:00
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Update.Providers;
namespace NzbDrone.Update.Test
{
[TestFixture]
class UpdateProviderVerifyTest
{
AutoMoqer mocker = new AutoMoqer();
[SetUp]
public void Setup()
{
mocker = new AutoMoqer();
mocker.GetMock<EnviromentProvider>()
.Setup(c => c.StartUpPath).Returns(@"C:\Temp\NzbDrone_update\");
}
[TestCase(null)]
[TestCase("")]
[TestCase(" ")]
2011-11-13 04:07:06 +00:00
public void update_should_throw_target_folder_is_blank(string target)
2011-10-23 18:31:17 +00:00
{
2011-11-13 04:07:06 +00:00
Assert.Throws<ArgumentException>(() => mocker.Resolve<UpdateProvider>().Start(target))
2011-10-23 18:31:17 +00:00
.Message.Should().StartWith("Target folder can not be null or empty");
}
[Test]
2011-11-13 04:07:06 +00:00
public void update_should_throw_if_target_folder_doesnt_exist()
2011-10-23 18:31:17 +00:00
{
string targetFolder = "c:\\NzbDrone\\";
2011-11-13 04:07:06 +00:00
Assert.Throws<DirectoryNotFoundException>(() => mocker.Resolve<UpdateProvider>().Start(targetFolder))
2011-10-23 18:31:17 +00:00
.Message.Should().StartWith("Target folder doesn't exist");
}
[Test]
2011-11-13 04:07:06 +00:00
public void update_should_throw_if_update_folder_doesnt_exist()
2011-10-23 18:31:17 +00:00
{
2011-11-13 04:07:06 +00:00
const string sandboxFolder = @"C:\Temp\NzbDrone_update\nzbdrone";
2011-10-23 18:31:17 +00:00
const string targetFolder = "c:\\NzbDrone\\";
mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(targetFolder))
.Returns(true);
mocker.GetMock<DiskProvider>()
.Setup(c => c.FolderExists(sandboxFolder))
.Returns(false);
2011-11-13 04:07:06 +00:00
Assert.Throws<DirectoryNotFoundException>(() => mocker.Resolve<UpdateProvider>().Start(targetFolder))
2011-10-23 18:31:17 +00:00
.Message.Should().StartWith("Update folder doesn't exist");
}
}
}