improved Linux support for tests.

pull/4/head
Keivan Beigi 12 years ago
parent 660185640d
commit 3162e4864d

@ -1,6 +1,6 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<ConsiderInconclusiveTestsAsPassing>true</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
@ -13,7 +13,10 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<ProxyProcessPath />
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>

@ -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>

@ -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\");
}
}
}

@ -229,7 +229,7 @@ namespace NzbDrone.Common
public static bool PathEquals(string firstPath, string secondPath)
{
return String.Equals(firstPath.NormalizePath(), secondPath.NormalizePath(), StringComparison.InvariantCultureIgnoreCase);
return String.Equals(firstPath.CleanPath(), secondPath.CleanPath(), StringComparison.InvariantCultureIgnoreCase);
}
public virtual void FileSetLastWriteTimeUtc(string path, DateTime dateTime)

@ -6,19 +6,19 @@ namespace NzbDrone.Common
{
public static class PathExtensions
{
private const string APP_DATA = "App_Data\\";
private const string APP_CONFIG_FILE = "config.xml";
private const string NZBDRONE_DB = "nzbdrone.db";
private const string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
private const string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update\\";
private const string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone\\";
private const string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup\\";
private const string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
private const string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update\\";
private const string UPDATE_LOG_FOLDER_NAME = "UpdateLogs\\";
public static string NormalizePath(this string path)
private static readonly string APP_DATA = "App_Data" + Path.DirectorySeparatorChar;
private static readonly string APP_CONFIG_FILE = "config.xml";
private static readonly string NZBDRONE_DB = "nzbdrone.db";
private static readonly string BACKUP_ZIP_FILE = "NzbDrone_Backup.zip";
private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "nzbdrone_update" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "nzbdrone" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_BACKUP_FOLDER_NAME = "nzbdrone_backup" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_CLIENT_EXE = "nzbdrone.update.exe";
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "NzbDrone.Update" + Path.DirectorySeparatorChar;
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar;
public static string CleanPath(this string path)
{
Ensure.That(() => path).IsNotNullOrWhiteSpace();

@ -1,6 +1,6 @@
namespace NzbDrone.Common
{
public static class StringExtention
public static class StringExtension
{
public static object NullSafe(this object target)

@ -70,7 +70,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
var episodeFile = Builder<EpisodeFile>.CreateNew()
.With(f => f.Id = 0)
.With(f => f.Path = path.NormalizePath())
.With(f => f.Path = path.CleanPath())
.Build();
Subject.Insert(episodeFile);
@ -79,7 +79,7 @@ namespace NzbDrone.Core.Test.MediaFileTests
//Resolve
file.Should().NotBeNull();
file.Path.Should().Be(path.NormalizePath());
file.Path.Should().Be(path.CleanPath());
}
}
}

@ -96,8 +96,11 @@ namespace NzbDrone.Core.Test.ParserTests
[TestCase("C:/Test/TV/Chuck.4x05.HDTV.XviD-LOL", 4, 5)]
[TestCase(@"P:\TV Shows\House\Season 6\S06E13 - 5 to 9 - 720p BluRay.mkv", 6, 13)]
[TestCase(@"S:\TV Drop\House - 10x11 - Title [SDTV]\1011 - Title.avi", 10, 11)]
[TestCase(@"/TV Drop/House - 10x11 - Title [SDTV]/1011 - Title.avi", 10, 11)]
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\1012 - 24 Hour Propane People.avi", 10, 12)]
[TestCase(@"/TV Drop/King of the Hill - 10x12 - 24 Hour Propane People [SDTV]/1012 - 24 Hour Propane People.avi", 10, 12)]
[TestCase(@"S:\TV Drop\King of the Hill - 10x12 - 24 Hour Propane People [SDTV]\Hour Propane People.avi", 10, 12)]
[TestCase(@"/TV Drop/King of the Hill - 10x12 - 24 Hour Propane People [SDTV]/Hour Propane People.avi", 10, 12)]
public void PathParse_tests(string path, int season, int episode)
{
var result = Parser.Parser.ParsePath(path);

@ -20,7 +20,7 @@ namespace NzbDrone.Core.Test.ParserTests
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.X-viD.AC3.-HELLYWOOD", Quality.DVD, false },
new object[] { "WEEDS.S03E01-06.DUAL.BDRip.AC3.-HELLYWOOD", Quality.DVD, false },
new object[] { "Two.and.a.Half.Men.S08E05.720p.HDTV.X264-DIMENSION", Quality.HDTV720p, false },
new object[] { "Chuck S11E03 has no periods or extention HDTV", Quality.SDTV, false },
new object[] { "Chuck S11E03 has no periods or extension HDTV", Quality.SDTV, false },
new object[] { "Chuck.S04E05.HDTV.XviD-LOL", Quality.SDTV, false },
new object[] { "The.Girls.Next.Door.S03E06.DVDRip.XviD-WiDE", Quality.DVD, false },
new object[] { "The.Girls.Next.Door.S03E06.DVD.Rip.XviD-WiDE", Quality.DVD, false },

@ -9,6 +9,7 @@ using NzbDrone.Common.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Update;
using NzbDrone.Test.Common;
using NzbDrone.Test.Common.Categories;
namespace NzbDrone.Core.Test.UpdateTests
{

@ -24,20 +24,9 @@ namespace NzbDrone.Core.Indexers.Nzbx
// "downvotes": 0
//}
public int Id { get; set; }
public string Name { get; set; }
public int TotalPart { get; set; }
public int GroupId { get; set; }
public long Size { get; set; }
public DateTime PostDate { get; set; }
public string Guid { get; set; }
public string FromName { get; set; }
public int Completion { get; set; }
public int CategoryId { get; set; }
public string ImdbId { get; set; }
public string AnidbId { get; set; }
public long RageId { get; set; }
public int Comments { get; set; }
public int Downloads { get; set; }
}
}

@ -81,7 +81,7 @@ namespace NzbDrone.Core.MediaFiles
_mediaFileRepository.DeleteMany(files);
}
public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extention)
public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extension)
{
string path = series.Path;
if (series.SeasonFolder)
@ -93,7 +93,7 @@ namespace NzbDrone.Core.MediaFiles
path = Path.Combine(path, seasonFolder);
}
path = Path.Combine(path, fileName + extention);
path = Path.Combine(path, fileName + extension);
return new FileInfo(path);
}

@ -96,11 +96,11 @@ namespace NzbDrone.Core.Providers
var episodeFile = new EpisodeFile();
episodeFile.DateAdded = DateTime.Now;
episodeFile.SeriesId = series.Id;
episodeFile.Path = filePath.NormalizePath();
episodeFile.Path = filePath.CleanPath();
episodeFile.Size = size;
episodeFile.Quality = parsedEpisode.Quality;
episodeFile.SeasonNumber = parsedEpisode.SeasonNumber;
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.NormalizePath());
episodeFile.SceneName = Path.GetFileNameWithoutExtension(filePath.CleanPath());
//Todo: We shouldn't actually import the file until we confirm its the only one we want.
//Todo: Separate episodeFile creation from importing (pass file to import to import)

@ -1,11 +1,11 @@
using NUnit.Framework;
namespace NzbDrone.Test.Common
namespace NzbDrone.Test.Common.Categories
{
public class IntegrationTestAttribute : CategoryAttribute
{
public IntegrationTestAttribute()
: base("Integration Test")
: base("IntegrationTest")
{
}

@ -41,7 +41,10 @@ namespace NzbDrone.Test.Common
[TearDown]
public void LoggingDownBase()
{
ExceptionVerification.AssertNoUnexcpectedLogs();
if (TestContext.CurrentContext.Result.Status == TestStatus.Passed)
{
ExceptionVerification.AssertNoUnexcpectedLogs();
}
}
}
}

@ -91,7 +91,7 @@
<Compile Include="AutoMoq\Unity\AutoMockingBuilderStrategy.cs" />
<Compile Include="AutoMoq\Unity\AutoMockingContainerExtension.cs" />
<Compile Include="ExceptionVerification.cs" />
<Compile Include="IntegrationTest.cs" />
<Compile Include="Categories\IntegrationTestAttribute.cs" />
<Compile Include="LoggingTest.cs" />
<Compile Include="MockerExtensions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -34,6 +34,7 @@ namespace NzbDrone.Test.Common
}
}
}
public abstract class TestBase : LoggingTest
@ -101,6 +102,20 @@ namespace NzbDrone.Test.Common
catch (Exception)
{
}
if (TestContext.CurrentContext.Result.Status == TestStatus.Failed)
{
var testName = TestContext.CurrentContext.Test.Name.ToLower();
if (EnvironmentProvider.IsLinux && testName.Contains("windows"))
{
throw new IgnoreException("windows specific test");
}
else if (testName.Contains("linux"))
{
throw new IgnoreException("linux specific test");
}
}
}
protected void WithTempAsAppPath()

@ -1,6 +1,6 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<ConsiderInconclusiveTestsAsPassing>true</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
@ -13,7 +13,10 @@
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<ProxyProcessPath />
<UseBuildConfiguration></UseBuildConfiguration>
<UseBuildPlatform />
<ProxyProcessPath></ProxyProcessPath>
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
<MSTestThreadApartmentState>STA</MSTestThreadApartmentState>
<BuildProcessArchitecture>x86</BuildProcessArchitecture>
</ProjectConfiguration>
Loading…
Cancel
Save