LibHac/tests/LibHac.Tests/Fs/FsaTests/MultiCommitTests.cs

64 lines
No EOL
1.8 KiB
C#

using System.Collections.Generic;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.Fs.Shim;
using LibHac.Tests.Fs.FileSystemClientTests;
using Xunit;
using static LibHac.Fs.SaveData;
namespace LibHac.Tests.Fs.FsaTests;
public class MultiCommitTests
{
[Fact]
public void Commit_MultipleFileSystems_AllFileSystemsAreCommitted()
{
FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
var saveInfo = new List<(int id, string name)>
{
(1, "Save1"),
(3, "Save2"),
(2, "Save3")
};
foreach ((int id, string name) info in saveInfo)
{
var applicationId = new Ncm.ApplicationId((uint)info.id);
fs.CreateSaveData(applicationId, InvalidUserId, 0, 0x4000, 0x4000, SaveDataFlags.None);
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
}
foreach ((int id, string name) info in saveInfo)
{
fs.CreateFile($"{info.name}:/file{info.id}".ToU8Span(), 0);
}
var names = new List<U8String>();
foreach ((int id, string name) info in saveInfo)
{
names.Add(info.name.ToU8String());
}
Assert.Success(fs.Commit(names.ToArray()));
foreach ((int id, string name) info in saveInfo)
{
fs.Unmount(info.name.ToU8Span());
}
foreach ((int id, string name) info in saveInfo)
{
var applicationId = new Ncm.ApplicationId((uint)info.id);
fs.MountSaveData(info.name.ToU8Span(), applicationId, InvalidUserId);
}
foreach ((int id, string name) info in saveInfo)
{
Assert.Success(fs.GetEntryType(out _, $"{info.name}:/file{info.id}".ToU8Span()));
}
}
}