51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
|
using System.Linq;
|
||
|
using Autofac;
|
||
|
using Nitride.IO.Contents;
|
||
|
using Nitride.IO.Paths;
|
||
|
using Xunit;
|
||
|
using Xunit.Abstractions;
|
||
|
using Zio;
|
||
|
using Zio.FileSystems;
|
||
|
|
||
|
namespace Nitride.IO.Tests
|
||
|
{
|
||
|
public class RemovePathPrefixTests : NitrideIOTestsBase
|
||
|
{
|
||
|
private readonly MemoryFileSystem fileSystem;
|
||
|
|
||
|
public RemovePathPrefixTests(ITestOutputHelper output)
|
||
|
: base(output)
|
||
|
{
|
||
|
this.fileSystem = new MemoryFileSystem();
|
||
|
this.fileSystem.CreateDirectory("/a");
|
||
|
this.fileSystem.CreateDirectory("/a/a");
|
||
|
this.fileSystem.CreateFile("/a/b1.txt");
|
||
|
this.fileSystem.CreateFile("/a/a/c1.md");
|
||
|
}
|
||
|
|
||
|
[Fact]
|
||
|
public void PrefixAllFiles()
|
||
|
{
|
||
|
// Set up the operation.
|
||
|
var readFiles = this.Container.Resolve<ReadFiles.Factory>();
|
||
|
var op = new RemovePathPrefix("/a");
|
||
|
|
||
|
// Read and replace the paths.
|
||
|
IOrderedEnumerable<string> output = readFiles(this.fileSystem)
|
||
|
.Read()
|
||
|
.Run(op)
|
||
|
.Select(x => x.Get<UPath>().ToString())
|
||
|
.OrderBy(x => x);
|
||
|
|
||
|
// Verify the results.
|
||
|
Assert.Equal(
|
||
|
new[]
|
||
|
{
|
||
|
"/a/c1.md",
|
||
|
"/b1.txt",
|
||
|
},
|
||
|
output);
|
||
|
}
|
||
|
}
|
||
|
}
|