mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-14 22:33:35 +01:00
45 lines
1.2 KiB
C#
45 lines
1.2 KiB
C#
// Copyright © WireMock.Net
|
|
|
|
using NFluent;
|
|
using System.IO;
|
|
using WireMock.Util;
|
|
using Xunit;
|
|
|
|
namespace WireMock.Net.Tests.Util;
|
|
|
|
public class FilePathUtilsTests
|
|
{
|
|
[Theory]
|
|
[InlineData(@"subdirectory/MyXmlResponse.xml")]
|
|
[InlineData(@"subdirectory\MyXmlResponse.xml")]
|
|
public void PathUtils_CleanPath(string path)
|
|
{
|
|
// Act
|
|
var cleanPath = FilePathUtils.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 = FilePathUtils.CleanPath(path);
|
|
|
|
// Act
|
|
var withoutDirectorySeparators = FilePathUtils.RemoveLeadingDirectorySeparators(cleanPath);
|
|
|
|
// Assert
|
|
Check.That(withoutDirectorySeparators).Equals(expected);
|
|
}
|
|
} |