Moved duplicated NormalizePath method to PathExtentions

This commit is contained in:
kay.one 2011-11-20 16:35:29 -08:00
commit 6778a6ed99
9 changed files with 54 additions and 60 deletions

View file

@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using FluentAssertions;
using Moq;
using NUnit.Framework;
@ -13,7 +14,7 @@ namespace NzbDrone.Common.Test
private EnviromentProvider GetEnviromentProvider()
{
var envMoq = new Mock<EnviromentProvider>();
envMoq.SetupGet(c => c.ApplicationPath).Returns(@"C:\NzbDrone\");
envMoq.SetupGet(c => c.SystemTemp).Returns(@"C:\Temp\");
@ -21,6 +22,32 @@ namespace NzbDrone.Common.Test
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]
[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();
}
[Test]
public void AppDataDirectory_path_test()