Files
WireMock.Net/test/WireMock.Net.Tests/Util/PathUtilsTests.cs
Stef Heyenrath d2a1d0f069 Fix WithBody when using Pact and added more nullable annotations (#783)
* More nullable annotations

* .

* .

* FIX

* pact

* .

* p

* xxx

* ...

* auth

* array

* ...
2022-08-11 10:57:33 +02:00

43 lines
1.1 KiB
C#

using NFluent;
using System.IO;
using WireMock.Util;
using Xunit;
namespace WireMock.Net.Tests.Util;
public class PathUtilsTests
{
[Theory]
[InlineData(@"subdirectory/MyXmlResponse.xml")]
[InlineData(@"subdirectory\MyXmlResponse.xml")]
public void PathUtils_CleanPath(string path)
{
// Act
var cleanPath = PathUtils.CleanPath(path);
// Assert
Check.That(cleanPath).Equals("subdirectory" + Path.DirectorySeparatorChar + "MyXmlResponse.xml");
}
[Theory]
[InlineData(null, null)]
[InlineData("", "")]
[InlineData("a", "a")]
[InlineData(@"/", "")]
[InlineData(@"//", "")]
[InlineData(@"//a", "a")]
[InlineData(@"\", "")]
[InlineData(@"\\", "")]
[InlineData(@"\\a", "a")]
public void PathUtils_CleanPath_RemoveLeadingDirectorySeparators(string path, string expected)
{
// Arrange
var cleanPath = PathUtils.CleanPath(path);
// Act
var withoutDirectorySeparators = PathUtils.RemoveLeadingDirectorySeparators(cleanPath);
// Assert
Check.That(withoutDirectorySeparators).Equals(expected);
}
}