mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-18 21:35:51 -04:00
Lots of initialization, configuration clean up.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using AutoMoq;
|
||||
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
@@ -7,6 +7,7 @@ using NzbDrone.Common;
|
||||
using NzbDrone.Core.Providers;
|
||||
using NzbDrone.Core.Providers.Core;
|
||||
using NzbDrone.Core.Test.Framework;
|
||||
using NzbDrone.Test.Common.AutoMoq;
|
||||
|
||||
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
{
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Ninject.Activation.Strategies;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Model;
|
||||
using NzbDrone.Core.Providers;
|
||||
@@ -13,44 +16,68 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
[TestFixture]
|
||||
internal class PreformUpdateFixture : CoreTest
|
||||
{
|
||||
|
||||
|
||||
private const string SANDBOX_FOLDER = @"C:\Temp\nzbdrone_update\";
|
||||
|
||||
[SetUp]
|
||||
public void setup()
|
||||
private readonly UpdatePackage updatePackage = new UpdatePackage
|
||||
{
|
||||
WithStrictMocker();
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/_test/NzbDrone.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Test]
|
||||
public void Should_download_update_package()
|
||||
{
|
||||
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<HttpProvider>().Verify(
|
||||
c => c.DownloadFile(updatePackage.Url, updateArchive));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Should_call_download_and_extract_using_correct_arguments()
|
||||
{
|
||||
Mocker.GetMock<EnviromentProvider>().SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/kayone/NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
var updateArchive = Path.Combine(SANDBOX_FOLDER, updatePackage.FileName);
|
||||
|
||||
Mocker.GetMock<HttpProvider>().Setup(
|
||||
c => c.DownloadFile(updatePackage.Url, updateArchive));
|
||||
|
||||
Mocker.GetMock<ArchiveProvider>().Setup(
|
||||
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<ArchiveProvider>().Verify(
|
||||
c => c.ExtractArchive(updateArchive, SANDBOX_FOLDER));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void should_start_update_client()
|
||||
{
|
||||
//Setup
|
||||
var updateClientPath = Mocker.GetMock<EnviromentProvider>().Object.GetUpdateClientExePath();
|
||||
|
||||
//Act
|
||||
Mocker.Resolve<UpdateProvider>().StartUpgrade(updatePackage);
|
||||
|
||||
//Assert
|
||||
Mocker.GetMock<ProcessProvider>().Verify(
|
||||
c => c.Start(It.Is<ProcessStartInfo>(p =>
|
||||
p.FileName == updateClientPath &&
|
||||
p.Arguments == "/12 /"
|
||||
)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Category(IntegrationTest)]
|
||||
public void Should_download_and_extract_to_temp_folder()
|
||||
{
|
||||
|
||||
@@ -58,13 +85,6 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
|
||||
var updateSubFolder = new DirectoryInfo(Mocker.GetMock<EnviromentProvider>().Object.GetUpdateSandboxFolder());
|
||||
|
||||
var updatePackage = new UpdatePackage
|
||||
{
|
||||
FileName = "NzbDrone.kay.one.0.6.0.2031.zip",
|
||||
Url = "http://update.nzbdrone.com/_test/NzbDrone.zip",
|
||||
Version = new Version("0.6.0.2031")
|
||||
};
|
||||
|
||||
|
||||
//Act
|
||||
updateSubFolder.Exists.Should().BeFalse();
|
||||
@@ -81,6 +101,5 @@ namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
||||
updateSubFolder.GetDirectories().Should().HaveCount(1);
|
||||
updateSubFolder.GetFiles().Should().HaveCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user