LibHac/tests/LibHac.Tests/Fs/FileSystemClientTests/ShimTests/BcatSaveData.cs

49 lines
1.6 KiB
C#
Raw Normal View History

using LibHac.Fs;
using LibHac.Fs.Fsa;
2020-04-04 23:19:36 +02:00
using LibHac.Fs.Shim;
using Xunit;
2021-11-14 20:08:57 +01:00
namespace LibHac.Tests.Fs.FileSystemClientTests.ShimTests;
public class BcatSaveData
2020-04-04 23:19:36 +02:00
{
2021-11-14 20:08:57 +01:00
[Fact]
public void MountBcatSaveData_SaveDoesNotExist_ReturnsTargetNotFound()
2020-04-04 23:19:36 +02:00
{
2021-11-14 20:08:57 +01:00
var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
Assert.Result(ResultFs.TargetNotFound, fs.MountBcatSaveData("bcat_test"u8, applicationId));
2021-11-14 20:08:57 +01:00
}
[Fact]
public void MountBcatSaveData_SaveExists_ReturnsSuccess()
{
var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
Assert.Success(fs.CreateBcatSaveData(applicationId, 0x400000));
Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId));
2021-11-14 20:08:57 +01:00
}
[Fact]
public void MountBcatSaveData_WrittenDataPersists()
{
var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
Assert.Success(fs.CreateBcatSaveData(applicationId, 0x400000));
Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId));
2021-11-14 20:08:57 +01:00
// Check that the path doesn't exist
Assert.Result(ResultFs.PathNotFound, fs.GetEntryType(out _, "bcat_test:/file"u8));
2021-11-14 20:08:57 +01:00
fs.CreateFile("bcat_test:/file"u8, 0);
fs.Commit("bcat_test"u8);
fs.Unmount("bcat_test"u8);
2021-11-14 20:08:57 +01:00
Assert.Success(fs.MountBcatSaveData("bcat_test"u8, applicationId));
Assert.Success(fs.GetEntryType(out DirectoryEntryType type, "bcat_test:/file"u8));
2021-11-14 20:08:57 +01:00
Assert.Equal(DirectoryEntryType.File, type);
2020-04-04 23:19:36 +02:00
}
}