62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
using MAB.DotIgnore;
|
|
|
|
using MfGames.Gallium;
|
|
using MfGames.Nitride.IO.Contents;
|
|
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
using Zio;
|
|
|
|
namespace MfGames.Nitride.IO.Tests.Paths;
|
|
|
|
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 = NitrideIOEnumerableEntityExtensions
|
|
.WhereNotIgnored(
|
|
(IEnumerable<Entity>)readFiles.WithPattern("/**")
|
|
.Run(),
|
|
ignore)
|
|
.Select(
|
|
x => x.Get<UPath>()
|
|
.ToString())
|
|
.OrderBy(x => x);
|
|
|
|
// Verify the results.
|
|
Assert.Equal(
|
|
new[]
|
|
{
|
|
"/c1.md",
|
|
},
|
|
output);
|
|
}
|
|
}
|