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/Nitride.IO.Tests/AddPathPrefixTests.cs
2021-12-06 00:55:57 -06:00

48 lines
1.3 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 AddPathPrefixTests : NitrideIOTestsBase
{
private readonly MemoryFileSystem fileSystem;
public AddPathPrefixTests(ITestOutputHelper output)
: base(output)
{
this.fileSystem = new MemoryFileSystem();
this.fileSystem.CreateFile("/b1.txt");
this.fileSystem.CreateFile("/c1.md");
}
[Fact]
public void PrefixAllFiles()
{
// Set up the operation.
var readFiles = this.Container.Resolve<ReadFiles.Factory>();
var op = new AddPathPrefix("/prefix");
// 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[]
{
"/prefix/b1.txt",
"/prefix/c1.md",
},
output);
}
}
}