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/Paths/WhereNotIgnoredTests.cs
2022-07-18 17:03:30 -05:00

58 lines
1.3 KiB
C#

using System.Linq;
using MAB.DotIgnore;
using Nitride.IO.Contents;
using Xunit;
using Xunit.Abstractions;
using Zio;
namespace Nitride.IO.Tests;
public class WhereNotIgnoredTests : NitrideIOTestBase
{
public WhereNotIgnoredTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void DoesIgnore()
{
// Set up the test.
using NitrideIOTestContext context = this.CreateContext();
// Set up the file.
IFileSystem fileSystem = context.FileSystem;
fileSystem.CreateFile("/b1.txt");
fileSystem.CreateFile("/c1.md");
fileSystem.CreateDirectory("/d");
fileSystem.CreateFile("/d/b2.txt");
// Set up the ignore file.
var ignore = new IgnoreList(new[] { "*.txt" });
// Set up the operation.
ReadFiles readFiles = context.Resolve<ReadFiles>();
// Read and replace the paths.
IOrderedEnumerable<string> output = readFiles.WithPattern("/**")
.Run()
.WhereNotIgnored(ignore)
.Select(
x => x.Get<UPath>()
.ToString())
.OrderBy(x => x);
// Verify the results.
Assert.Equal(
new[]
{
"/c1.md",
},
output);
}
}