2011-10-23 10:32:57 -07:00
|
|
|
// ReSharper disable InconsistentNaming
|
|
|
|
|
2011-11-08 09:48:34 -08:00
|
|
|
using System;
|
2011-10-23 10:32:57 -07:00
|
|
|
using System.IO;
|
|
|
|
using FluentAssertions;
|
|
|
|
using NUnit.Framework;
|
2011-11-13 10:16:31 -08:00
|
|
|
using NzbDrone.Test.Common;
|
2011-10-23 10:32:57 -07:00
|
|
|
|
|
|
|
namespace NzbDrone.Common.Test
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2011-11-13 10:16:31 -08:00
|
|
|
public class EnviromentProviderTest : TestBase
|
2011-10-23 10:32:57 -07:00
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
readonly EnvironmentProvider environmentProvider = new EnvironmentProvider();
|
2011-10-23 10:32:57 -07:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void StartupPath_should_not_be_empty()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
environmentProvider.StartUpPath.Should().NotBeBlank();
|
|
|
|
Path.IsPathRooted(environmentProvider.StartUpPath).Should().BeTrue("Path is not rooted");
|
2011-10-23 10:32:57 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void ApplicationPath_should_not_be_empty()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
environmentProvider.ApplicationPath.Should().NotBeBlank();
|
|
|
|
Path.IsPathRooted(environmentProvider.ApplicationPath).Should().BeTrue("Path is not rooted");
|
2011-10-23 10:32:57 -07:00
|
|
|
}
|
2011-10-23 22:54:09 -07:00
|
|
|
|
2011-11-02 19:09:00 -07:00
|
|
|
|
|
|
|
[Test]
|
2011-11-20 19:42:45 -08:00
|
|
|
public void ApplicationPath_should_find_root_in_current_folder()
|
2011-11-02 19:09:00 -07:00
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
Directory.CreateDirectory(EnvironmentProvider.ROOT_MARKER);
|
|
|
|
environmentProvider.ApplicationPath.Should().BeEquivalentTo(Directory.GetCurrentDirectory());
|
2011-11-02 19:09:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-20 19:42:45 -08:00
|
|
|
[Test]
|
|
|
|
public void crawl_should_return_null_if_cant_find_root()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
environmentProvider.CrawlToRoot("C:\\").Should().BeNullOrEmpty();
|
2011-11-20 19:42:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void should_go_up_the_tree_to_find_iis()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
environmentProvider.ApplicationPath.Should().NotBe(Environment.CurrentDirectory);
|
|
|
|
environmentProvider.ApplicationPath.Should().NotBe(environmentProvider.StartUpPath);
|
2011-11-20 19:42:45 -08:00
|
|
|
}
|
2011-10-23 22:54:09 -07:00
|
|
|
[Test]
|
|
|
|
public void IsProduction_should_return_false_when_run_within_nunit()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
EnvironmentProvider.IsProduction.Should().BeFalse();
|
2011-10-23 22:54:09 -07:00
|
|
|
}
|
2011-11-08 09:48:34 -08:00
|
|
|
|
|
|
|
[TestCase("0.0.0.0")]
|
|
|
|
[TestCase("1.0.0.0")]
|
|
|
|
public void Application_version_should_not_be_default(string version)
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
environmentProvider.Version.Should().NotBe(new Version(version));
|
2011-11-08 09:48:34 -08:00
|
|
|
}
|
2011-11-20 19:42:45 -08:00
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
public void TearDown()
|
|
|
|
{
|
2012-03-06 18:59:43 -08:00
|
|
|
if (Directory.Exists(EnvironmentProvider.ROOT_MARKER))
|
|
|
|
Directory.Delete(EnvironmentProvider.ROOT_MARKER);
|
2011-11-20 19:42:45 -08:00
|
|
|
}
|
2011-10-23 10:32:57 -07:00
|
|
|
}
|
|
|
|
}
|