LibHac/tests/LibHac.Tests/Fs/IFileSystemTestBase/IFileSystemTests.CleanDirectoryRecursively.cs

33 lines
958 B
C#
Raw Normal View History

using LibHac.Fs;
using LibHac.Fs.Fsa;
using Xunit;
2021-11-14 20:08:57 +01:00
namespace LibHac.Tests.Fs.IFileSystemTestBase;
public abstract partial class IFileSystemTests
{
2021-11-14 20:08:57 +01:00
[Fact]
public void CleanDirectoryRecursively_DeletesChildren()
{
2021-11-14 20:08:57 +01:00
IFileSystem fs = CreateFileSystem();
2021-11-14 20:08:57 +01:00
fs.CreateDirectory("/dir");
fs.CreateDirectory("/dir/dir2");
fs.CreateFile("/dir/file1", 0, CreateFileOptions.None);
2021-11-14 20:08:57 +01:00
Result rcDelete = fs.CleanDirectoryRecursively("/dir");
2021-11-14 20:08:57 +01:00
Result rcDir1Type = fs.GetEntryType(out DirectoryEntryType dir1Type, "/dir");
Result rcDir2Type = fs.GetEntryType(out _, "/dir/dir2");
Result rcFileType = fs.GetEntryType(out _, "/dir/file1");
2021-11-14 20:08:57 +01:00
Assert.Success(rcDelete);
2021-11-14 20:08:57 +01:00
Assert.Success(rcDir1Type);
Assert.Equal(DirectoryEntryType.Directory, dir1Type);
2021-11-14 20:08:57 +01:00
Assert.Result(ResultFs.PathNotFound, rcDir2Type);
Assert.Result(ResultFs.PathNotFound, rcFileType);
}
2021-11-14 20:08:57 +01:00
}