1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Update.Test/InstallUpdateServiceFixture.cs

59 lines
1.8 KiB
C#
Raw Normal View History

using System;
2011-10-23 21:31:17 +03:00
using System.IO;
using FluentAssertions;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
2011-11-13 21:16:31 +03:00
using NzbDrone.Test.Common;
2013-05-21 07:03:05 +03:00
using NzbDrone.Update.UpdateEngine;
2011-10-23 21:31:17 +03:00
namespace NzbDrone.Update.Test
{
[TestFixture]
public class InstallUpdateServiceFixture : TestBase<InstallUpdateService>
2011-10-23 21:31:17 +03:00
{
[SetUp]
public void Setup()
{
Mocker.GetMock<IAppFolderInfo>()
.Setup(c => c.TempFolder).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
{
Assert.Throws<ArgumentException>(() => Subject.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\\";
Assert.Throws<DirectoryNotFoundException>(() => Subject.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\\";
2013-05-11 02:53:50 +03:00
Mocker.GetMock<IDiskProvider>()
2011-10-23 21:31:17 +03:00
.Setup(c => c.FolderExists(targetFolder))
.Returns(true);
2013-05-11 02:53:50 +03:00
Mocker.GetMock<IDiskProvider>()
2011-10-23 21:31:17 +03:00
.Setup(c => c.FolderExists(sandboxFolder))
.Returns(false);
Assert.Throws<DirectoryNotFoundException>(() => Subject.Start(targetFolder))
2011-10-23 21:31:17 +03:00
.Message.Should().StartWith("Update folder doesn't exist");
}
}
}