2011-11-21 03:35:29 +03:00
|
|
|
using System;
|
|
|
|
using System.Linq;
|
2011-11-14 03:22:18 +03:00
|
|
|
using FluentAssertions;
|
2011-11-13 10:27:16 +03:00
|
|
|
using Moq;
|
|
|
|
using NUnit.Framework;
|
2011-11-13 21:16:31 +03:00
|
|
|
using NzbDrone.Test.Common;
|
2011-11-13 10:27:16 +03:00
|
|
|
|
2011-11-14 03:22:18 +03:00
|
|
|
namespace NzbDrone.Common.Test
|
2011-11-13 10:27:16 +03:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2011-11-13 21:16:31 +03:00
|
|
|
public class PathExtentionFixture : TestBase
|
2011-11-13 10:27:16 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
private EnviromentProvider GetEnviromentProvider()
|
|
|
|
{
|
|
|
|
var envMoq = new Mock<EnviromentProvider>();
|
2011-11-21 03:35:29 +03:00
|
|
|
|
2011-11-13 10:27:16 +03:00
|
|
|
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
|
|
|
|
|
2011-11-14 04:27:11 +03:00
|
|
|
envMoq.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
|
|
|
|
2011-11-13 10:27:16 +03:00
|
|
|
return envMoq.Object;
|
2011-11-14 03:22:18 +03:00
|
|
|
}
|
2011-11-13 10:27:16 +03:00
|
|
|
|
2011-11-21 03:35:29 +03:00
|
|
|
[TestCase(@"c:\test\", @"c:\test")]
|
|
|
|
[TestCase(@"c:\\test\\", @"c:\test")]
|
|
|
|
[TestCase(@"C:\\Test\\", @"C:\Test")]
|
|
|
|
[TestCase(@"C:\\Test\\Test\", @"C:\Test\Test")]
|
|
|
|
[TestCase(@"\\Testserver\Test\", @"\\Testserver\Test")]
|
|
|
|
public void Normalize_Path(string dirty, string clean)
|
|
|
|
{
|
|
|
|
var result = dirty.NormalizePath();
|
|
|
|
result.Should().Be(clean);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
|
|
|
|
public void normalize_path_exception_empty()
|
|
|
|
{
|
|
|
|
"".NormalizePath();
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
[ExpectedException(typeof(ArgumentException), ExpectedMessage = "Path can not be null or empty")]
|
|
|
|
public void normalize_path_exception_null()
|
|
|
|
{
|
|
|
|
string nullPath = null;
|
|
|
|
nullPath.NormalizePath();
|
|
|
|
}
|
|
|
|
|
2011-11-13 10:27:16 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void AppDataDirectory_path_test()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\App_Data\");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Config_path_test()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void IISConfig_path_test()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetIISConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\AppServer\applicationhost.config");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void IISExe_path_test()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetIISExe().Should().BeEquivalentTo(@"C:\NzbDrone\IISExpress\IISExpress.exe");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void NlogConfig_path_test()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetNlogConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\NzbDrone.Web\log.config");
|
|
|
|
}
|
2011-11-14 04:27:11 +03:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void Sanbox()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetUpdatePackageFolder()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetUpdateClientFolder()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\");
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void GetUpdateClientExePath()
|
|
|
|
{
|
|
|
|
GetEnviromentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\NzbDrone.Update.exe");
|
|
|
|
}
|
2011-11-13 10:27:16 +03:00
|
|
|
}
|
|
|
|
}
|