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

30 lines
936 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 DeleteDirectoryRecursively_DeletesDirectoryAndChildren()
{
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);
Result resultDelete = fs.DeleteDirectoryRecursively("/dir");
Result resultDir1Type = fs.GetEntryType(out _, "/dir");
Result resultDir2Type = fs.GetEntryType(out _, "/dir/dir2");
Result resultFileType = fs.GetEntryType(out _, "/dir/file1");
Assert.Success(resultDelete);
Assert.Result(ResultFs.PathNotFound, resultDir1Type);
Assert.Result(ResultFs.PathNotFound, resultDir2Type);
Assert.Result(ResultFs.PathNotFound, resultFileType);
}
}