2011-10-21 08:04:26 +03:00
|
|
|
using System;
|
2011-11-14 03:22:18 +03:00
|
|
|
|
2011-10-21 08:04:26 +03:00
|
|
|
using FluentAssertions;
|
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
2011-10-29 07:54:33 +03:00
|
|
|
using NzbDrone.Common;
|
2013-02-24 09:48:52 +03:00
|
|
|
using NzbDrone.Core.Configuration;
|
2011-10-21 08:04:26 +03:00
|
|
|
using NzbDrone.Core.Providers;
|
|
|
|
using NzbDrone.Core.Providers.Core;
|
|
|
|
using NzbDrone.Core.Test.Framework;
|
2011-11-14 03:22:18 +03:00
|
|
|
using NzbDrone.Test.Common.AutoMoq;
|
2011-10-21 08:04:26 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Test.ProviderTests.UpdateProviderTests
|
|
|
|
{
|
2013-02-17 08:44:06 +03:00
|
|
|
class GetAvilableUpdateFixture : CoreTest
|
2011-10-21 08:04:26 +03:00
|
|
|
{
|
|
|
|
private static Version _latestsTestVersion = new Version("0.6.0.3");
|
|
|
|
private static string _latestsTestUrl = "http://update.nzbdrone.com/_test/NzbDrone.master.0.6.0.3.zip";
|
|
|
|
private static string _latestsTestFileName = "NzbDrone.master.0.6.0.3.zip";
|
|
|
|
|
|
|
|
[SetUp]
|
2012-02-05 09:34:36 +03:00
|
|
|
public void Setup()
|
2011-10-21 08:04:26 +03:00
|
|
|
{
|
2011-12-15 07:15:53 +03:00
|
|
|
WithStrictMocker();
|
2011-10-21 08:04:26 +03:00
|
|
|
|
2013-02-24 09:48:52 +03:00
|
|
|
Mocker.GetMock<ConfigService>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/_test/");
|
2011-12-15 07:15:53 +03:00
|
|
|
Mocker.Resolve<HttpProvider>();
|
2011-10-21 08:04:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase("0.6.0.9")]
|
|
|
|
[TestCase("0.7.0.1")]
|
|
|
|
[TestCase("1.0.0.0")]
|
|
|
|
public void should_return_null_if_latests_is_lower_than_current_version(string currentVersion)
|
|
|
|
{
|
|
|
|
|
2012-02-05 09:34:36 +03:00
|
|
|
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(new Version(currentVersion));
|
2011-10-21 08:04:26 +03:00
|
|
|
|
|
|
|
updatePackage.Should().BeNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_return_null_if_latests_is_equal_to_current_version()
|
|
|
|
{
|
2012-02-05 09:34:36 +03:00
|
|
|
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(_latestsTestVersion);
|
2011-10-21 08:04:26 +03:00
|
|
|
|
|
|
|
updatePackage.Should().BeNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestCase("0.0.0.0")]
|
|
|
|
[TestCase("0.0.0.1")]
|
|
|
|
[TestCase("0.0.10.10")]
|
|
|
|
public void should_return_update_if_latests_is_higher_than_current_version(string currentVersion)
|
|
|
|
{
|
2012-02-05 09:34:36 +03:00
|
|
|
var updatePackage = Mocker.Resolve<UpdateProvider>().GetAvilableUpdate(new Version(currentVersion));
|
2011-10-21 08:04:26 +03:00
|
|
|
|
|
|
|
updatePackage.Should().NotBeNull();
|
|
|
|
updatePackage.Version.Should().Be(_latestsTestVersion);
|
|
|
|
updatePackage.FileName.Should().BeEquivalentTo(_latestsTestFileName);
|
|
|
|
updatePackage.Url.Should().BeEquivalentTo(_latestsTestUrl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|