mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-14 10:47:08 -07:00
improved Linux support for tests.
This commit is contained in:
parent
660185640d
commit
3162e4864d
20 changed files with 178 additions and 149 deletions
|
@ -83,7 +83,7 @@
|
|||
<Compile Include="EventingTests\MessageAggregatorEventTests.cs" />
|
||||
<Compile Include="ReflectionExtensions.cs" />
|
||||
<Compile Include="ReportingService_ReportParseError_Fixture.cs" />
|
||||
<Compile Include="PathExtentionFixture.cs" />
|
||||
<Compile Include="PathExtensionFixture.cs" />
|
||||
<Compile Include="DiskProviderFixture.cs" />
|
||||
<Compile Include="EnviromentProviderTest.cs" />
|
||||
<Compile Include="ProcessProviderTests.cs" />
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<ProjectConfiguration>
|
||||
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
|
||||
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
|
||||
<ConsiderInconclusiveTestsAsPassing>true</ConsiderInconclusiveTestsAsPassing>
|
||||
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
|
||||
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
|
||||
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
|
||||
|
@ -44,9 +44,6 @@
|
|||
<RegexTestSelector>
|
||||
<RegularExpression>NzbDrone\.Common\.Test\.EventingTests\.ServiceNameFixture\..*</RegularExpression>
|
||||
</RegexTestSelector>
|
||||
<RegexTestSelector>
|
||||
<RegularExpression>NzbDrone\.Common\.Test\.PathExtentionFixture\..*</RegularExpression>
|
||||
</RegexTestSelector>
|
||||
<RegexTestSelector>
|
||||
<RegularExpression>NzbDrone\.Common\.Test\.ProcessProviderTests\..*</RegularExpression>
|
||||
</RegexTestSelector>
|
||||
|
|
118
NzbDrone.Common.Test/PathExtensionFixture.cs
Normal file
118
NzbDrone.Common.Test/PathExtensionFixture.cs
Normal file
|
@ -0,0 +1,118 @@
|
|||
using System;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathExtensionFixture : TestBase
|
||||
{
|
||||
|
||||
private EnvironmentProvider GetEnvironmentProvider()
|
||||
{
|
||||
var fakeEnvironment = new Mock<EnvironmentProvider>();
|
||||
|
||||
fakeEnvironment.SetupGet(c => c.WorkingDirectory).Returns(@"C:\NzbDrone\");
|
||||
|
||||
fakeEnvironment.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
return fakeEnvironment.Object;
|
||||
}
|
||||
|
||||
[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")]
|
||||
[TestCase(@"\\Testserver\\Test\", @"\\Testserver\Test")]
|
||||
[TestCase(@"\\Testserver\Test\file.ext", @"\\Testserver\Test\file.ext")]
|
||||
[TestCase(@"\\Testserver\Test\file.ext\\", @"\\Testserver\Test\file.ext")]
|
||||
[TestCase(@"\\Testserver\Test\file.ext \\", @"\\Testserver\Test\file.ext")]
|
||||
public void Normalize_Path_Windows(string dirty, string clean)
|
||||
{
|
||||
var result = dirty.CleanPath();
|
||||
result.Should().Be(clean);
|
||||
}
|
||||
|
||||
[TestCase(@"/test/", @"/test")]
|
||||
[TestCase(@"//test/", @"/test")]
|
||||
[TestCase(@"//test//", @"/test")]
|
||||
[TestCase(@"//test// ", @"/test")]
|
||||
[TestCase(@"//test//other// ", @"/test/other")]
|
||||
[TestCase(@"//test//other//file.ext ", @"/test/other/file.ext")]
|
||||
[TestCase(@"//CAPITAL//lower// ", @"/CAPITAL/lower")]
|
||||
public void Normalize_Path_Linux(string dirty, string clean)
|
||||
{
|
||||
var result = dirty.CleanPath();
|
||||
result.Should().Be(clean);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void normalize_path_exception_empty()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => "".CleanPath());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void normalize_path_exception_null()
|
||||
{
|
||||
string nullPath = null;
|
||||
Assert.Throws<ArgumentException>(() => nullPath.CleanPath());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetEnvironmentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetEnvironmentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Sanbox()
|
||||
{
|
||||
GetEnvironmentProvider().GetUpdateSandboxFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUpdatePackageFolder()
|
||||
{
|
||||
GetEnvironmentProvider().GetUpdatePackageFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUpdateClientFolder()
|
||||
{
|
||||
GetEnvironmentProvider().GetUpdateClientFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone\NzbDrone.Update\");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUpdateClientExePath()
|
||||
{
|
||||
GetEnvironmentProvider().GetUpdateClientExePath().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\NzbDrone.Update.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSandboxLogFolder()
|
||||
{
|
||||
GetEnvironmentProvider().GetSandboxLogFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\UpdateLogs\");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUpdateLogFolder()
|
||||
{
|
||||
GetEnvironmentProvider().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using NzbDrone.Test.Common;
|
||||
|
||||
namespace NzbDrone.Common.Test
|
||||
{
|
||||
[TestFixture]
|
||||
public class PathExtentionFixture : TestBase
|
||||
{
|
||||
|
||||
private EnvironmentProvider GetEnviromentProvider()
|
||||
{
|
||||
var envMoq = new Mock<EnvironmentProvider>();
|
||||
|
||||
envMoq.SetupGet(c => c.WorkingDirectory).Returns(@"C:\NzbDrone\");
|
||||
|
||||
envMoq.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
|
||||
|
||||
return envMoq.Object;
|
||||
}
|
||||
|
||||
[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]
|
||||
public void normalize_path_exception_empty()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(()=> "".NormalizePath());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void normalize_path_exception_null()
|
||||
{
|
||||
string nullPath = null;
|
||||
Assert.Throws<ArgumentException>(() => nullPath.NormalizePath());
|
||||
ExceptionVerification.ExpectedWarns(1);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void AppDataDirectory_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetAppDataPath().Should().BeEquivalentTo(@"C:\NzbDrone\App_Data\");
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Config_path_test()
|
||||
{
|
||||
GetEnviromentProvider().GetConfigPath().Should().BeEquivalentTo(@"C:\NzbDrone\Config.xml");
|
||||
}
|
||||
|
||||
[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.Update.exe");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetSandboxLogFolder()
|
||||
{
|
||||
GetEnviromentProvider().GetSandboxLogFolder().Should().BeEquivalentTo(@"C:\Temp\Nzbdrone_update\UpdateLogs\");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetUpdateLogFolder()
|
||||
{
|
||||
GetEnviromentProvider().GetUpdateLogFolder().Should().BeEquivalentTo(@"C:\NzbDrone\UpdateLogs\");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue