This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/tests/MfGames.Nitride.IO.Tests/Paths/RemovePathPrefixTest.cs

59 lines
1.4 KiB
C#
Raw Normal View History

using System.Linq;
2022-09-06 05:53:22 +00:00
using MfGames.Nitride.IO.Contents;
using MfGames.Nitride.IO.Paths;
using Xunit;
using Xunit.Abstractions;
using Zio;
2022-09-06 05:53:22 +00:00
namespace MfGames.Nitride.IO.Tests;
public class RemovePathPrefixTest : NitrideIOTestBase
{
public RemovePathPrefixTest(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void PrefixAllFiles()
{
// Set up the test.
using NitrideIOTestContext context = this.CreateContext();
// Set up the file.
IFileSystem fileSystem = context.FileSystem;
fileSystem.CreateDirectory("/a");
fileSystem.CreateDirectory("/a/a");
fileSystem.CreateFile("/a/b1.txt");
fileSystem.CreateFile("/a/a/c1.md");
// Set up the operation.
ReadFiles readFiles = context.Resolve<ReadFiles>();
2022-07-09 04:52:10 +00:00
RemovePathPrefix op = context.Resolve<RemovePathPrefix>()
.WithPathPrefix("/a");
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.Run(op)
2022-07-09 04:52:10 +00:00
.Select(
x => x.Get<UPath>()
.ToString())
.OrderBy(x => x);
// Verify the results.
Assert.Equal(
new[]
{
"/a/c1.md",
"/b1.txt",
},
output);
}
}